- All Superinterfaces:
- All Known Implementing Classes:
- public interface Locator
- extends Accessor
A locator is a coat-check, of sorts, for a (key,element) pair inside
a KeyBasedContainer. If you give the container a pair to hold, the
container gives you back a locator, and you can later ask the
container to do useful things with the locator. For example, one
thing you can do is have
the container stop storing the pair, by passing the locator to the
container's remove(.) method.
What Locator adds to Accessor is the association between the
element and a key (contrast Position, which adds the association
between the element and a topological "place" in the container).
No guarantee is made by KeyBasedContainer about the way in
which the locators and the associated pairs are stored.
A different locator is associated with each reference to a pair
that you ask the container to store. That is, if you put the same
pair into a container twice, or the same key or element, the pairs' locators
will not be the same. However, if the container moves a pair
around, the locator follows the pair. That is, a locator is
associated with one stored reference to a pair, no matter where
that reference is stored in the container.
The implementation of locators is not specified, beyond this
interface. However, the point of locators is to allow faster
access to arbitrary elements stored in the container than would be
possible by simply searching the container for them, so they should
not be implemented with a simple linear search. They might be references
to node objects or indices into arrays.
- $Id: Locator.java,v 1.4 2000/01/12 03:21:32 mdh Exp $
- Mark Handy (mdh), Andrew Schwerin (schwerin)
- See Also:
public java.lang.Object key()
- the key associated with the locator
InvalidAccessorException - if the locator has been
removed from its container