Opus5
Class StackAsArray
java.lang.Object
|
+--Opus5.AbstractObject
|
+--Opus5.AbstractContainer
|
+--Opus5.StackAsArray
- All Implemented Interfaces:
- Comparable, Container, Stack
- public class StackAsArray
- extends AbstractContainer
- implements Stack
A stack implemented using an array.
- Version:
- $Id: StackAsArray.java,v 3.3 1998/07/28 03:09:15 brpreiss Exp $
- Author:
- Bruno R. Preiss, P.Eng.
|
Field Summary |
protected java.lang.Object[] |
array
The array. |
|
Constructor Summary |
StackAsArray(int size)
Constructs a StackAsArray with the specified array length. |
|
Method Summary |
void |
accept(Visitor visitor)
Accepts a visitor and makes it visit all the object in this stack. |
protected int |
compareTo(Comparable arg)
Compares this stack with the specified comparable object. |
Enumeration |
getEnumeration()
Returns an enumberation that enumerates the objects in this stack. |
java.lang.Object |
getTop()
Returns the object at the top of this stack. |
boolean |
isFull()
Tests whether this stack is full. |
java.lang.Object |
pop()
Pops and returns the object from the top of this stack. |
void |
purge()
Purges this stack, making it empty. |
void |
push(java.lang.Object object)
Pushes the specified object onto this stack. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
array
protected java.lang.Object[] array
- The array.
StackAsArray
public StackAsArray(int size)
- Constructs a
StackAsArray with the specified array length.
- Parameters:
size - The desired array length.
purge
public void purge()
- Purges this stack, making it empty.
- Specified by:
purge in interface Container
push
public void push(java.lang.Object object)
- Pushes the specified object onto this stack.
- Specified by:
push in interface Stack
- Parameters:
object - The object to be pushed onto this stack.- Throws:
ContainerFullException - If the stack is full.
pop
public java.lang.Object pop()
- Pops and returns the object from the top of this stack.
- Specified by:
pop in interface Stack
- Returns:
- The object from the top of this stack.
- Throws:
ContainerEmptyException - If this stack is empty.
getTop
public java.lang.Object getTop()
- Returns the object at the top of this stack.
- Specified by:
getTop in interface Stack
- Returns:
- The object at the top of this stack.
- Throws:
ContainerEmptyException - If this stack is empty.
accept
public void accept(Visitor visitor)
- Accepts a visitor and makes it visit all the object in this stack.
- Specified by:
accept in interface Container- Overrides:
accept in class AbstractContainer
- Parameters:
visitor - The visitor to be accepted.
getEnumeration
public Enumeration getEnumeration()
- Returns an enumberation that enumerates the objects in this stack.
- Specified by:
getEnumeration in interface Container
- Returns:
- An enumberation that enumerates the objects in this stack.
isFull
public boolean isFull()
- Tests whether this stack is full.
- Specified by:
isFull in interface Container- Overrides:
isFull in class AbstractContainer
- Returns:
- True if this stack is full; false otherwise.
compareTo
protected int compareTo(Comparable arg)
- Compares this stack with the specified comparable object.
This method is not implemented.
- Overrides:
compareTo in class AbstractObject
- Parameters:
arg - The comparable object with which this stack is compared.- Throws:
MethodNotImplemented - Always.