|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
A Container in which each element in its structure is associated with a key. This association is known as a mapping.
KeyBasedContainers may be viewed abstractly as storing pairs of the type, p(k,e) where
| Method Summary | |
void |
insert(Locator locator)
Inserts a Locator into this Container. |
Locator |
insert(java.lang.Object key,
java.lang.Object element)
Inserts a <key, element> pair into this Container. |
java.util.Enumeration |
keys()
Returns an enumeration of all of the keys of all the locators in the Container. |
java.util.Enumeration |
locators()
Returns an Enumeration of all the Locators within this Container. |
Locator |
makeLocator(java.lang.Object key,
java.lang.Object element)
For when you need a locator that can be inserted into this KeyBasedContainer but don't want to insert it quite yet. |
void |
remove(Locator locator)
Removes an element from this Container. |
java.lang.Object |
replaceElement(Locator loc,
java.lang.Object newElement)
Takes constant time -- even in key-based containers, since the element can be changed independently of the key. |
java.lang.Object |
replaceKey(Locator locator,
java.lang.Object key)
Changes the mapping of a Locator's element to a new key. |
| Methods inherited from interface jdsl.core.api.Container |
elements,
newContainer |
| Methods inherited from interface jdsl.simple.api.SimpleContainer |
isEmpty,
size |
| Method Detail |
public void insert(Locator locator)
throws InvalidKeyException,
InvalidLocatorException,
ContainedLocatorException
locator - The Locator whose key and element are inserted into
this Container.locator is not a type accepted by
this Container. (For instance, if the container's Comparator
can't compare the element, or if the container should have
a comparator but doesn't.)locator
cannot be inserted into this container.
public Locator insert(java.lang.Object key,
java.lang.Object element)
throws InvalidKeyException
key is an explicit key. That is, it is mapped to
element and used to position element within
this Container.key - The key used to position the element
within this Container.element - The element to be inserted into this
Container.element
within this Container.key
is not a type accepted by this Container. (For instance, if
the container's Comparator
can't compare the element, or if the container should have
a comparator but doesn't.)
public void remove(Locator locator)
throws InvalidLocatorException,
UncontainedLocatorException
locator - The Locator which points to a particular
element within this Container.locator is
invalid.locator
is not in a container.
public java.lang.Object replaceKey(Locator locator,
java.lang.Object key)
throws InvalidLocatorException,
InvalidKeyException
locator's element will now be mapped to
key. The original key this element was mapped to is returned
Note: this method does not necessarily remove the old key (other
elements within this Container may be mapped to it).locator - The Locator which points to a particular
element within this Container.key - The new key to which locator's
element should be mapped.locator's element
was mapped.locator is
invalid (For example: It does not actually reference
an element in this Container).key
is not a type accepted by this Container (e.g. If
this Container is unable to use key
as a key).
public java.lang.Object replaceElement(Locator loc,
java.lang.Object newElement)
throws InvalidLocatorException
loc - Locator at which replacement should occurnewElement - Element now to be stored at Locator locpublic java.util.Enumeration locators()
public java.util.Enumeration keys()
public Locator makeLocator(java.lang.Object key,
java.lang.Object element)
throws InvalidKeyException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||