structure5
Interface Structure<E>

All Superinterfaces:
Iterable<E>
All Known Subinterfaces:
Graph<V,E>, Linear<E>, List<E>, OrderedStructure<K>, Queue<E>, Set<E>, Stack<E>
All Known Implementing Classes:
AbstractLinear, AbstractList, AbstractQueue, AbstractSet, AbstractStack, AbstractStructure, BinarySearchTree, CircularList, DoublyLinkedList, GraphList, GraphListDirected, GraphListUndirected, GraphMatrix, GraphMatrixDirected, GraphMatrixUndirected, OrderedList, OrderedVector, QueueArray, QueueList, QueueVector, RedBlackSearchTree, SetList, SetVector, SinglyLinkedList, SplayTree, StackArray, StackList, StackVector, Vector

public interface Structure<E>
extends Iterable<E>

The interface of a basic, mutable data structure.

This interface is the basis for most mutable structures in the structure package. While most methods are easy implement, it is often sufficient to simply extend a basic, abstract implementation of this class, the AbstractStructure. The AbstractStructure implements the isEmpty, contains and collection methods. They may be overridden if a particularly efficient technique is to be preferred.

Since:
Java Structures, 2nd edition

Method Summary
 void add(E value)
          Inserts value in some structure-specific location.
 void clear()
          Removes all elements from the structure.
 boolean contains(E value)
          Determines if the structure contains a value.
 Enumeration elements()
          Returns an enumeration for traversing the structure.
 boolean isEmpty()
          Determine if there are elements within the structure.
 Iterator<E> iterator()
          Returns an iterator for traversing the structure.
 E remove(E value)
          Removes value from the structure.
 int size()
          Determine the size of the structure.
 Collection<E> values()
          Returns a java.util.Collection wrapping this structure.
 

Method Detail

size

int size()
Determine the size of the structure.

Returns:
the size of the structure

isEmpty

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

Returns:
true if the structure is empty; false otherwise

clear

void clear()
Removes all elements from the structure.


contains

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

Parameters:
value - non-null value to be found within structure
Returns:
true when some value equals value

add

void add(E value)
Inserts value in some structure-specific location.

Parameters:
value - the value to be added to the structure; non-null

remove

E remove(E value)
Removes value from the structure.

Parameters:
value - value matching the value to be removed
Returns:
returns the value that was replaced, or null if none.

elements

Enumeration elements()
Returns an enumeration for traversing the structure.

Returns:
an enumeration for traversing the structure
See Also:
AbstractIterator, Iterator, Enumeration, iterator()

iterator

Iterator<E> iterator()
Returns an iterator for traversing the structure.

Specified by:
iterator in interface Iterable<E>
Returns:
an iterator for traversing the structure
See Also:
AbstractIterator, Iterator, Enumeration, elements()

values

Collection<E> values()
Returns a java.util.Collection wrapping this structure.

Returns:
a Collection that is equivalent to this structure