structure
Class AbstractStructure

java.lang.Object
  extended by structure.AbstractStructure
All Implemented Interfaces:
Structure
Direct Known Subclasses:
AbstractLinear, AbstractList, AbstractSet, BinarySearchTree, GraphList, GraphMatrix, OrderedList, OrderedVector

public abstract class AbstractStructure
extends Object
implements Structure

An abstract implementation of a basic, mutable data structure.

This abstract implementation of the Structure interface provides a good starting point for the implementation of a basic, mutable data structure. This implementation provides a workable implementation of isEmpty, contains, and values.

Where more efficient implementations are possible, the user may wish to override these methods. For example, an implementor may have a structure directly implement the java.util.Collection interface and have the value method simply return this. Because of peculiarities of both systems of designing data structures, it is often best to avoid direct implementation java.util.Collection and Structure in one class.

Since:
Java Structures, 2nd edition

Constructor Summary
AbstractStructure()
          The default constructor.
 
Method Summary
 boolean contains(Object value)
          Determines if the structure contains a value.
 Enumeration elements()
          Return an enumeration associated with this structure.
 int hashCode()
           
 boolean isEmpty()
          Determine if there are elements within the structure.
 Collection values()
          Returns a java.util.Collection wrapping this structure.
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface structure.Structure
add, clear, iterator, remove, size
 

Constructor Detail

AbstractStructure

public AbstractStructure()
The default constructor. Initializes any internal variables.

Method Detail

isEmpty

public boolean isEmpty()
Determine if there are elements within the structure.

Specified by:
isEmpty in interface Structure
Returns:
true if the structure is empty; false otherwise

elements

public Enumeration elements()
Return an enumeration associated with this structure. This implementation returns an AbstractIterator which supports both enumeration at iterator techniques.

Specified by:
elements in interface Structure
Returns:
a Enumeration for traversing the structure
See Also:
AbstractIterator, Iterator, Enumeration

contains

public boolean contains(Object value)
Determines if the structure contains a value.

Specified by:
contains in interface Structure
Parameters:
value - non-null value to be found within structure
Returns:
true when some value equals value

hashCode

public int hashCode()
Overrides:
hashCode in class Object

values

public Collection values()
Returns a java.util.Collection wrapping this structure. This particular implementation returns a StructCollection whose methods may not provide the most efficent implementations of non-Structure Collection methods.

Specified by:
values in interface Structure
Returns:
a Collection that is equivalent to this structure
See Also:
StructCollection, Collection