Class jgl.Stack
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jgl.Stack

java.lang.Object
   |
   +----jgl.Stack

public class Stack
extends Object
implements Container
A Stack is an adapter that allows you to use any Sequence as a first-in, last-out data structure. By default, a Stack uses an Array.

See Also:
Sequence, Array, StackExamples

Constructor Index

 o Stack()
Construct myself to be an empty Stack.
 o Stack(Sequence)
Construct myself with a specified Sequence as my underlying implementation.
 o Stack(Stack)
Construct myself to be a shallow copy of a specified Stack.

Method Index

 o add(Object)
Push an object.
 o clear()
Remove all of my objects.
 o clone()
Return a shallow copy of myself.
 o copy(Stack)
Become a shallow copy of a specified Stack.
 o elements()
Return an Enumeration of my components.
 o equals(Object)
Return true if object is a Stack whose underlying sequence is equal to mine.
 o equals(Stack)
Return true if a specified Stack's sequence is equal to mine.
 o finish()
Return an iterator positioned immediately afer my last item.
 o hashCode()
Return my hash code for support of hashing containers
 o isEmpty()
Return true if I contain no objects.
 o maxSize()
Return the maximum number of objects that I can contain.
 o pop()
Pop the last object that was pushed onto me.
 o push(Object)
Push an object.
 o size()
Return the number of objects that I contain.
 o start()
Return an iterator positioned at my first item.
 o swap(Stack)
Swap my contents with another Stack.
 o top()
Return the last object that was pushed onto me.
 o toString()
Return a string that describes me.

Constructors

 o Stack
  public Stack()
Construct myself to be an empty Stack. Use an Array for my underlying implementation.
 o Stack
  public Stack(Sequence sequence)
Construct myself with a specified Sequence as my underlying implementation.
Parameters:
sequence - The empty Sequence to be used for my implementation.
 o Stack
  public Stack(Stack stack)
Construct myself to be a shallow copy of a specified Stack.
Parameters:
stack - The Stack to be copied.

Methods

 o copy
  public void copy(Stack stack)
Become a shallow copy of a specified Stack. A shallow copy is made of the Stack's underlying sequence.
Parameters:
stack - The Stack to be copied.
 o clone
  public Object clone()
Return a shallow copy of myself.
Overrides:
clone in class Object
 o toString
  public String toString()
Return a string that describes me.
Overrides:
toString in class Object
 o equals
  public boolean equals(Object object)
Return true if object is a Stack whose underlying sequence is equal to mine.
Parameters:
object - Any object.
Overrides:
equals in class Object
 o equals
  public boolean equals(Stack stack)
Return true if a specified Stack's sequence is equal to mine.
Parameters:
stack - The Stack to compare myself against.
 o hashCode
  public int hashCode()
Return my hash code for support of hashing containers
Overrides:
hashCode in class Object
 o isEmpty
  public boolean isEmpty()
Return true if I contain no objects.
 o size
  public int size()
Return the number of objects that I contain.
 o maxSize
  public int maxSize()
Return the maximum number of objects that I can contain.
 o top
  public Object top()
Return the last object that was pushed onto me.
Throws: InvalidOperationException
if the Stack is empty.
 o add
  public Object add(Object object)
Push an object. Return null as add's always work for Stacks
Parameters:
object - The object to push.
 o push
  public void push(Object object)
Push an object.
Parameters:
object - The object to push.
 o pop
  public Object pop()
Pop the last object that was pushed onto me.
Throws: InvalidOperationException
if the Stack is empty.
 o clear
  public void clear()
Remove all of my objects.
 o elements
  public Enumeration elements()
Return an Enumeration of my components.
 o start
  public ForwardIterator start()
Return an iterator positioned at my first item.
 o finish
  public ForwardIterator finish()
Return an iterator positioned immediately afer my last item.
 o swap
  public void swap(Stack stack)
Swap my contents with another Stack.
Parameters:
stack - The Stack that I will swap my contents with.

All Packages  Class Hierarchy  This Package  Previous  Next  Index