|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
IntStack
abstracts a last-in-first-out
dynamically-growable list of integers. All the methods are standard
except for the peel()
method, which pops
n
items off the stack and returns the new "uncovered"
top item on the stack (like peeling a banana).
Method Summary | |
boolean |
contains(int value)
Returns true if the stack contains the given
value, false otherwise. |
boolean |
isEmpty()
Returns true if the stack has no elements,
false otherwise. |
int |
peek()
Returns the top element of the stack. |
int |
peel(int len)
Pops len elements off the stack and returns the
top item on the stack (a peek() ). |
int |
pop()
Pops the top element off the stack. |
void |
push(int value)
Pushes the given element to the top of the stack. |
int |
size()
Returns the depth of the stack. |
Method Detail |
public void push(int value)
public int pop()
public int peel(int len)
len
elements off the stack and returns the
top item on the stack (a peek()
).public int peek()
public int size()
public boolean contains(int value)
true
if the stack contains the given
value, false
otherwise.public boolean isEmpty()
true
if the stack has no elements,
false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |