structure5
Class AbstractStructure<E>

java.lang.Object
  extended by structure5.AbstractStructure<E>
All Implemented Interfaces:
Iterable<E>, Structure<E>
Direct Known Subclasses:
AbstractLinear, AbstractList, AbstractSet, BinarySearchTree, GraphList, GraphMatrix, OrderedList, OrderedVector, RedBlackSearchTree

public abstract class AbstractStructure<E>
extends Object
implements Structure<E>

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(E value)
          Determines if the structure contains a value.
 Enumeration<E> elements()
          Return an enumeration associated with this structure.
 int hashCode()
           
 boolean isEmpty()
          Determine if there are elements within the structure.
 Collection<E> 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 structure5.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<E>
Returns:
true if the structure is empty; false otherwise

elements

public Enumeration<E> 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<E>
Returns:
a Enumeration for traversing the structure
See Also:
AbstractIterator, Iterator, Enumeration

contains

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

Specified by:
contains in interface Structure<E>
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<E> 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<E>
Returns:
a Collection that is equivalent to this structure
See Also:
structure.StructCollection, Collection