com.inxar.syntacs.util
Class ArrayIntStack

java.lang.Object
  |
  +--com.inxar.syntacs.util.ArrayIntStack
All Implemented Interfaces:
IntStack, Serializable

public class ArrayIntStack
extends Object
implements IntStack, Serializable

Concrete implementation of IntStack which uses an array internally.

See Also:
Serialized Form

Constructor Summary
ArrayIntStack()
          Constructs the ArrayIntStack using a default capacity.
ArrayIntStack(int capacity)
          Constructs the ArrayIntStack with the given initial capacity.
 
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 i)
          Pushes the given element to the top of the stack.
 int size()
          Returns the depth of the stack.
 IntArray toIntArray()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayIntStack

public ArrayIntStack(int capacity)
Constructs the ArrayIntStack with the given initial capacity.

ArrayIntStack

public ArrayIntStack()
Constructs the ArrayIntStack using a default capacity.
Method Detail

push

public void push(int i)
Description copied from interface: IntStack
Pushes the given element to the top of the stack.
Specified by:
push in interface IntStack

pop

public int pop()
Description copied from interface: IntStack
Pops the top element off the stack.
Specified by:
pop in interface IntStack

peel

public int peel(int len)
Description copied from interface: IntStack
Pops len elements off the stack and returns the top item on the stack (a peek()).
Specified by:
peel in interface IntStack

peek

public int peek()
Description copied from interface: IntStack
Returns the top element of the stack.
Specified by:
peek in interface IntStack

isEmpty

public boolean isEmpty()
Description copied from interface: IntStack
Returns true if the stack has no elements, false otherwise.
Specified by:
isEmpty in interface IntStack

contains

public boolean contains(int value)
Description copied from interface: IntStack
Returns true if the stack contains the given value, false otherwise.
Specified by:
contains in interface IntStack

size

public int size()
Description copied from interface: IntStack
Returns the depth of the stack.
Specified by:
size in interface IntStack

toIntArray

public IntArray toIntArray()

toString

public String toString()
Overrides:
toString in class Object