public class SizeLimitedStack<T>
extends java.lang.Object
Constructor and Description |
---|
SizeLimitedStack(int sizeLimit)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Empty the stack.
|
T |
peek()
Looks at the object at the top of this stack without removing it from the
stack.
|
T |
pop()
Removes the object at the top of this stack and returns that object as
the value of this function.
|
void |
push(T e)
Pushes an item onto the top of this stack.
|
int |
size()
Returns the number of elements in this stack.
|
java.lang.Object[] |
toArray()
Return an array of all elements in the stack.
|
public SizeLimitedStack(int sizeLimit)
sizeLimit
- the maximum number of elements in the stack. If the stack is
full, the oldest element will be removed when new element was
pushed.public void push(T e)
e
- the item to be pushed onto this stack.public T pop()
java.util.NoSuchElementException
- if this list is emptypublic T peek()
java.util.NoSuchElementException
- if this list is emptypublic void clear()
public java.lang.Object[] toArray()
public int size()