All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.objectspace.jgl.Stack

java.lang.Object
   |
   +----COM.objectspace.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 remove(Enumeration)
Remove the element at a particular position.
 o remove(Enumeration, Enumeration)
Remove the elements in the specified range.
 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 synchronized 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 synchronized Object clone()
Return a shallow copy of myself.

Overrides:
clone in class Object
 o toString
  public synchronized 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 synchronized 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 synchronized 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 synchronized Object top()
Return the last object that was pushed onto me.

Throws: InvalidOperationException
if the Stack is empty.
 o add
  public synchronized 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 synchronized Object pop()
Pop the last object that was pushed onto me.

Throws: InvalidOperationException
if the Stack is empty.
 o clear
  public synchronized void clear()
Remove all of my objects.

 o elements
  public synchronized Enumeration elements()
Return an Enumeration of my components.

 o start
  public synchronized ForwardIterator start()
Return an iterator positioned at my first item.

 o finish
  public synchronized ForwardIterator finish()
Return an iterator positioned immediately afer my last item.

 o swap
  public synchronized void swap(Stack stack)
Swap my contents with another Stack.

Parameters:
stack - The Stack that I will swap my contents with.
 o remove
  public Object remove(Enumeration pos)
Remove the element at a particular position.

Parameters:
pos - The enumeration representing of the object to remove.
Throws: InvalidOperationException
Thrown by default.
 o remove
  public int remove(Enumeration first,
                    Enumeration last)
Remove the elements in the specified range.

Parameters:
pos - The enumeration representing of the object to remove.
Throws: InvalidOperationException
Thrown by default.

All Packages  Class Hierarchy  This Package  Previous  Next  Index