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.
 
Fields inherited from class Opus5.AbstractContainer
count
 
Fields inherited from interface Opus5.Stack
copyright
 
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 Opus5.AbstractContainer
getCount, hashCode, isEmpty, toString
 
Methods inherited from class Opus5.AbstractObject
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Opus5.Container
getCount, isEmpty
 
Methods inherited from interface Opus5.Comparable
compare, isEQ, isGE, isGT, isLE, isLT, isNE
 

Field Detail

array

protected java.lang.Object[] array
The array.
Constructor Detail

StackAsArray

public StackAsArray(int size)
Constructs a StackAsArray with the specified array length.
Parameters:
size - The desired array length.
Method Detail

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.