All Packages Class Hierarchy This Package Previous Next Index
Interface rpi.goldsd.container.AssociativeContainer
- public interface AssociativeContainer
The AssociativeContainer interface defines the methods
required to implement a mapping or hashtable-like container object.
One of the most important aspects of this interface is the
use of a Comparable object as the key argument
to the add(), map(), and remove()
methods. This key will likely be a unique key; however, this
restriction is neither imposed nor enforced by this interface.
Note that the add() method is
defined to potentially throw a DuplicateElementException
exception if the key is implemented as a unique key and this
unique constraint is violated during run-time.
- Version:
- 1.1.2, 4/16/98
- Author:
- David Goldschmidt
- See Also:
- Comparable, DuplicateElementException, Table
-
add(Comparable)
- Adds a new associative entry to this associative container.
-
add(Comparable, Object)
- Adds a new associative entry to this associative container.
-
clear()
- Removes all elements from this associative container.
-
contains(Comparable)
- Returns true if the given key maps to an element in
this associative container.
-
elements()
- Provides an enumeration of the data stored in this container.
-
getSize()
- Returns the number of elements in this container.
-
isEmpty()
- Returns true if this container contains no elements.
-
keys()
- Provides an enumeration of the keys stored in this container.
-
map(Comparable)
- Provides a mechanism for mapping a given key to its corresponding data.
-
remove(Comparable)
- Removes a data element from this container identified by the given key.
add
public abstract void add(Comparable keyAndData) throws DuplicateElementException
- Adds a new associative entry to this associative container.
Note that the single argument consists of both the key and
the actual data to be stored in this associative container.
- Parameters:
- keyAndData - the key used to identify the data, as well
as the actual data to be stored.
- Throws: DuplicateElementException
- if a unique key is used
and the key used already exists in this container.
add
public abstract void add(Comparable key,
Object data) throws DuplicateElementException
- Adds a new associative entry to this associative container.
- Parameters:
- key - the key used to identify the associated data.
- data - the actual data to be stored.
- Throws: DuplicateElementException
- if a unique key is used
and the key used already exists in this container.
clear
public abstract void clear()
- Removes all elements from this associative container.
contains
public abstract boolean contains(Comparable key)
- Returns true if the given key maps to an element in
this associative container.
- Parameters:
- key - the key used to identify an element in this
associative container.
- Returns:
- true if the given key maps to an element in
this associative container; false otherwise.
elements
public abstract Enumeration elements()
- Provides an enumeration of the data stored in this container.
- Returns:
- an enumeration of the elements stored in this container.
getSize
public abstract int getSize()
- Returns the number of elements in this container.
- Returns:
- the number of elements in this container.
isEmpty
public abstract boolean isEmpty()
- Returns true if this container contains no elements.
- Returns:
- true if this container contains no elements;
false otherwise.
keys
public abstract Enumeration keys()
- Provides an enumeration of the keys stored in this container.
- Returns:
- an enumeration of the keys stored in this container.
map
public abstract Object map(Comparable key)
- Provides a mechanism for mapping a given key to its corresponding data.
- Parameters:
- key - the key used to identify and locate the associated data.
- Returns:
- the data stored in the container indexed by the given key;
or null if the key does not map to a data object
in this container.
remove
public abstract Object remove(Comparable key)
- Removes a data element from this container identified by the given key.
- Parameters:
- key - the key used to identify and locate the associated data.
- Returns:
- the object that is removed from the container; or null
if the key does not map to a data object in this container.
All Packages Class Hierarchy This Package Previous Next Index