org.inxar.syntacs.util
Interface IntStack

All Known Implementing Classes:
ArrayIntStack

public interface IntStack

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

push

public void push(int value)
Pushes the given element to the top of the stack.

pop

public int pop()
Pops the top element off the stack.

peel

public int peel(int len)
Pops len elements off the stack and returns the top item on the stack (a peek()).

peek

public int peek()
Returns the top element of the stack.

size

public int size()
Returns the depth of the stack.

contains

public boolean contains(int value)
Returns true if the stack contains the given value, false otherwise.

isEmpty

public boolean isEmpty()
Returns true if the stack has no elements, false otherwise.