Constructor and Description |
---|
FastStack() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the stack.
|
boolean |
contains(E element)
Returns if the stack contains the specified element.
|
boolean |
isEmpty()
Returns whether the stack is empty.
|
Iterator<E> |
iterator()
Returns an iterator that goes from the oldest element to the newest.
|
static <T> FastStack<T> |
newInstance()
Factory method to create a new instance.
|
E |
peek()
Returns the entry at the top of the stack without removing it.
|
E |
peek(int index)
Return the element at the specified index.
|
E |
pop()
Returns the entry at the top of the stack by removing it.
|
void |
push(E element)
Pushes the supplied element onto the stack.
|
int |
size()
Returns the number of entries in the stack.
|
public FastStack()
public void push(E element)
element
- the element to push onto the stack.public boolean isEmpty()
public int size()
public E peek()
IllegalStateException
- if the stack is empty.public E pop()
IllegalStateException
- if the stack is empty.public E peek(int index)
index
- the index to returnIllegalArgumentException
- if index out of rangepublic boolean contains(E element)
element
- the element to findpublic void clear()
public Iterator<E> iterator()
public static <T> FastStack<T> newInstance()
T
- the type of elements to hold in the stack.FastStack
Copyright © 2001–2015. All rights reserved.