jdsl.core.api
Interface KeyBasedContainer
- All Superinterfaces:
- Container, InspectableContainer, InspectableKeyBasedContainer
- All Known Subinterfaces:
- Dictionary, OrderedDictionary, PriorityQueue
- public interface KeyBasedContainer
- extends InspectableKeyBasedContainer, Container
Key-based containers are containers that store (key,element) pairs;
each pair is represented by a Locator. The keys might or might not
be ordered. The elements are entirely arbitrary, as far as the
container is concerned. Attaching a key to every element allows
the container to perform key-based retrievals of elements later.
Key-based containers allow duplicate keys, elements, or pairs,
but there is a unique locator associated with each insertion of
a pair.
Users can implement no-duplicates semantics on top of key-based
containers if required.
- Version:
- $Id: KeyBasedContainer.java,v 1.4 2000/01/12 03:21:31 mdh Exp $
- Author:
- Mark Handy, Andrew Schwerin, Luca Vismara
- See Also:
InspectableKeyBasedContainer
,
Container
,
Locator
Method Summary |
Locator |
insert(java.lang.Object key,
java.lang.Object element)
Inserts a (key,element) pair into this container. |
void |
remove(Locator loc)
Removes a (key,element) pair from the container. |
java.lang.Object |
replaceKey(Locator loc,
java.lang.Object key)
Replaces the key in the given (key,element) pair, adjusting the
container as necessary. |
insert
public Locator insert(java.lang.Object key,
java.lang.Object element)
throws InvalidKeyException
- Inserts a (key,element) pair into this container.
- Parameters:
key
- the key associated with the specified element.element
- the element to insert into the container.- Returns:
- a locator associated with the inserted pair.
- Throws:
InvalidKeyException
- if key
cannot be used
by this container
remove
public void remove(Locator loc)
throws InvalidAccessorException
- Removes a (key,element) pair from the container.
- Parameters:
loc
- a locator in the container to remove- Throws:
InvalidAccessorException
- if the locator is not valid or
is not contained by this container
replaceKey
public java.lang.Object replaceKey(Locator loc,
java.lang.Object key)
throws InvalidAccessorException,
InvalidKeyException
- Replaces the key in the given (key,element) pair, adjusting the
container as necessary.
- Parameters:
loc
- the locator in the container whose key should be replacedkey
- the new key to associate with loc
.- Returns:
- The old key
- Throws:
InvalidAccessorException
- If the locator is not valid
or is not contained by this containerInvalidKeyException
- If key
cannot be used
by this container