|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.redfelineninja.util.IntStack
This stack class represents a last-in-first-out (LIFO) stack of integers.
In some cases speed is of paramount importance, in such cases
java.util.Stack
should be avoided since its use forces object
creation. Object creation is time consuming.
The method names used in this class are taken from java.util.Vector
and java.util.Stack
so there should be little memory
burdon in using this class.
Constructor Summary | |
IntStack()
Creates an empty stack with the default initial size. |
|
IntStack(int size)
Creates an empty stack with specified initial size. |
Method Summary | |
boolean |
empty()
Test whether or not the stack is empty. |
int |
peek()
Peek at the top of the stack. |
int |
pop()
Pop an item off the stack. |
void |
push(int item)
Push an item onto the stack. |
int |
size()
Get the size of the stack. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public IntStack()
public IntStack(int size)
size
- initial size and capacity incrementMethod Detail |
public final void push(int item)
item
- the item to be pushedpublic final int pop()
public final int peek()
public final boolean empty()
public final int size()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |