| JGL - The Generic Collection Library for Java |
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, Stack examples
-
mySequence
-
-
Stack()
- Construct myself to be an empty Stack.
-
Stack(Sequence)
- Construct myself with a specified Sequence as my underlying implementation.
-
Stack(Stack)
- Construct myself to be a shallow copy of a specified Stack.
-
add(Object)
- Push an object.
-
clear()
- Remove all of my objects.
-
clone()
- Return a shallow copy of myself.
-
copy(Stack)
- Become a shallow copy of a specified Stack.
-
elements()
- Return an Enumeration of my components.
-
equals(Object)
- Return true if object is a Stack whose underlying sequence is equal to mine.
-
equals(Stack)
- Return true if a specified Stack's sequence is equal to mine.
-
finish()
- Return an iterator positioned immediately afer my last item.
-
hashCode()
- Return my hash code for support of hashing containers
-
isEmpty()
- Return true if I contain no objects.
-
maxSize()
- Return the maximum number of objects that I can contain.
-
pop()
- Pop the last object that was pushed onto me.
-
push(Object)
- Push an object.
-
remove(Enumeration)
- Remove the element at a particular position.
-
remove(Enumeration, Enumeration)
- Remove the elements in the specified range.
-
size()
- Return the number of objects that I contain.
-
start()
- Return an iterator positioned at my first item.
-
swap(Stack)
- Swap my contents with another Stack.
-
top()
- Return the last object that was pushed onto me.
-
toString()
- Return a string that describes me.
mySequence
protected Sequence mySequence
Stack
public Stack()
- Construct myself to be an empty Stack.
Use an Array for my underlying implementation.
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.
Stack
public Stack(Stack stack)
- Construct myself to be a shallow copy of a specified Stack.
- Parameters:
- stack - The Stack to be copied.
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.
clone
public synchronized Object clone()
- Return a shallow copy of myself.
- Overrides:
- clone in class Object
toString
public synchronized String toString()
- Return a string that describes me.
- Overrides:
- toString in class Object
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
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.
hashCode
public synchronized int hashCode()
- Return my hash code for support of hashing containers
- Overrides:
- hashCode in class Object
isEmpty
public boolean isEmpty()
- Return true if I contain no objects.
size
public int size()
- Return the number of objects that I contain.
maxSize
public int maxSize()
- Return the maximum number of objects that I can contain.
top
public synchronized Object top()
- Return the last object that was pushed onto me.
- Throws: InvalidOperationException
- if the Stack is empty.
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.
push
public void push(Object object)
- Push an object.
- Parameters:
- object - The object to push.
pop
public synchronized Object pop()
- Pop the last object that was pushed onto me.
- Throws: InvalidOperationException
- if the Stack is empty.
clear
public synchronized void clear()
- Remove all of my objects.
elements
public synchronized Enumeration elements()
- Return an Enumeration of my components.
start
public synchronized ForwardIterator start()
- Return an iterator positioned at my first item.
finish
public synchronized ForwardIterator finish()
- Return an iterator positioned immediately afer my last item.
swap
public synchronized void swap(Stack stack)
- Swap my contents with another Stack.
- Parameters:
- stack - The Stack that I will swap my contents with.
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.
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