E
- Type of elements on the stack.public class CircularStack<E>
extends java.lang.Object
implements java.lang.Iterable<E>
Constructor and Description |
---|
CircularStack(int limit)
Creates circular stack with at most limit elements.
|
Modifier and Type | Method and Description |
---|---|
java.util.Iterator<E> |
iterator() |
E |
peek()
Gets most recently added element.
|
void |
pop()
Removes most recently added element.
|
void |
push(E element)
Adds element to the stack.
|
void |
shallowCopyTo(CircularStack<E> destination)
Creates shallow copy in destination.
|
int |
size()
Returns size of a stack.
|
public CircularStack(int limit)
limit
- Maximum number of elements on the stack.public void shallowCopyTo(CircularStack<E> destination)
destination
- CircularStack to which elements should be copied.public void push(E element)
element
- Element to be added.public E peek()
public void pop()
public int size()