jdsl
Interface Container

All Known Subinterfaces:
BinaryTree, BookSequence, CircularSequence, Dictionary, Graph, InspectableGraph, InspectableTree, KeyBasedContainer, OrderedDictionary, PositionalContainer, PositionalSequence, PriorityQueue, RankedSequence, RestructurableBinaryTree, Sequence, SimpleDictionary, SimplePriorityQueue, Tree

public abstract interface Container

A container is a collection of elements, each of which is a generic Object. An element can be stored multiple times in a container.

This is the base interface for all the container interfaces in the "core" package (e.g., Sequence, PriorityQueue), by way of the subinterfaces PositionalContainer and KeyBasedContainer.

See Also:
PositionalContainer, KeyBasedContainer, jdsl.simple.api.Container

Method Summary
 java.util.Iterator elements()
          Returns an Iterator of the elements stored in the container.
 boolean isEmpty()
          Tests if the container is empty.
 Container newContainer()
          Instantiates another container of the same class (without knowing the class).
 int size()
          Return the number of elements stored in the container, where each element is counted according to is multiplicity.
 

Method Detail

size

public int size()
Return the number of elements stored in the container, where each element is counted according to is multiplicity.
Returns:
number of elements in the container.

isEmpty

public boolean isEmpty()
Tests if the container is empty.
Returns:
true if the container is empty, false otherwise.

elements

public java.util.Iterator elements()
Returns an Iterator of the elements stored in the container. Duplicated elements appear in the Iterator as many times as they are held in the container. For some containers, the order of the elements in the Iterator is arbitrary, but for some it is defined.
Returns:
Iterator of all elements in the container

newContainer

public Container newContainer()
                       throws InvalidContainerException
Instantiates another container of the same class (without knowing the class).
Returns:
a new instance of the class of the container on which the method is called