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

Method Index

 o add(Comparable)
Adds a new associative entry to this associative container.
 o add(Comparable, Object)
Adds a new associative entry to this associative container.
 o clear()
Removes all elements from this associative container.
 o contains(Comparable)
Returns true if the given key maps to an element in this associative container.
 o elements()
Provides an enumeration of the data stored in this container.
 o getSize()
Returns the number of elements in this container.
 o isEmpty()
Returns true if this container contains no elements.
 o keys()
Provides an enumeration of the keys stored in this container.
 o map(Comparable)
Provides a mechanism for mapping a given key to its corresponding data.
 o remove(Comparable)
Removes a data element from this container identified by the given key.

Methods

 o 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.
 o 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.
 o clear
 public abstract void clear()
Removes all elements from this associative container.

 o 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.
 o 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.
 o getSize
 public abstract int getSize()
Returns the number of elements in this container.

Returns:
the number of elements in this container.
 o isEmpty
 public abstract boolean isEmpty()
Returns true if this container contains no elements.

Returns:
true if this container contains no elements; false otherwise.
 o 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.
 o 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.
 o 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