Opus5
Class AbstractContainer
java.lang.Object
|
+--Opus5.AbstractObject
|
+--Opus5.AbstractContainer
- All Implemented Interfaces:
- Comparable, Container
- Direct Known Subclasses:
- AbstractGraph, AbstractSearchableContainer, AbstractTree, BinaryHeap, BinomialQueue, Deap, QueueAsArray, QueueAsLinkedList, StackAsArray, StackAsLinkedList
- public abstract class AbstractContainer
- extends AbstractObject
- implements Container
The AbstractContainer is the base class
from which all concrete container classes are derived.
This abstract class provides default implementations
for various methods declared in the Container interface.
- Version:
- $Id: AbstractContainer.java,v 3.3 1998/07/28 12:52:15 brpreiss Exp $
- Author:
- Bruno R. Preiss, P.Eng.
- See Also:
Container
|
Field Summary |
protected int |
count
The number of objects in this container. |
|
Method Summary |
void |
accept(Visitor visitor)
Accepts a visitor and as long is its isDone method
returns false this method calls the visitor's visit method
for each object in this container. |
int |
getCount()
Returns the number of objects in this container. |
int |
hashCode()
Returns a hashcode for this container. |
boolean |
isEmpty()
Tests if this container is empty. |
boolean |
isFull()
Tests if this container is full. |
java.lang.String |
toString()
Returns a string representation of the contents of this container. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
count
protected int count
- The number of objects in this container.
AbstractContainer
public AbstractContainer()
getCount
public int getCount()
- Returns the number of objects in this container.
- Specified by:
getCount in interface Container
- Returns:
- The number of objects in this container.
isEmpty
public boolean isEmpty()
- Tests if this container is empty.
The default implementation returns true if the
getCount
method returns zero.
- Specified by:
isEmpty in interface Container
- Returns:
- True if this container is empty; false otherwise.
isFull
public boolean isFull()
- Tests if this container is full.
The default implementation always returns false.
- Specified by:
isFull in interface Container
- Returns:
- True if this container is full; false otherwise.
accept
public void accept(Visitor visitor)
- Accepts a visitor and as long is its
isDone method
returns false this method calls the visitor's visit method
for each object in this container.
The default implementation calls the getEnumeration method
to obtain an enumeration that enumerates the objects in this container.
- Specified by:
accept in interface Container
- Parameters:
visitor - The visitor to accept.- See Also:
Visitor,
Container.getEnumeration(),
Enumeration
toString
public java.lang.String toString()
- Returns a string representation of the contents of this container.
- Overrides:
toString in class java.lang.Object
- Returns:
- A string representation of the contents of this container.
The default implementation returns a string comprised of the
name of this class followed by a comma-speparated list
of the string representations of the objects in this container.
hashCode
public int hashCode()
- Returns a hashcode for this container.
The default implementation sums up the hashcodes of the objects
contained in this container and returns the sum
plus the hashcode returned by the class of this class.
- Overrides:
hashCode in class java.lang.Object
- Returns:
- A hashcode for this container.
- See Also:
HashTable