net.cscott.jutil

Class Indexer<T>

public abstract class Indexer<T> extends Object

Indexer is an object for extracting unique indices for a set of objects. It is commonly generated by Factories for some class of objects, which can then generate and store unique integers in the objects that they are used to construct. This way auxilliary data structures can efficiently index objects that belong to a common Factory without that data-structure needing an explict dependency on that particular Factory or Object type.

Version: $Id: Indexer.java,v 1.1 2003/03/20 01:58:20 cananian Exp $

Author: Felix S. Klock II

Method Summary
TgetByID(int id)
Provides a reverse mapping for the index returned by getID.
abstract intgetID(T o)
Returns the "small" integer uniquely associated with o in this.
booleanimplementsReverseMapping()
Tells user whether this particular Indexer implements the getByID() method.

Method Detail

getByID

public T getByID(int id)
Provides a reverse mapping for the index returned by getID. The constraint is that getByID(getID(o)) must equal o for all objects indexed by this.

Throws: UnsupportedOperationException if this functionality is not supported by this.

getID

public abstract int getID(T o)
Returns the "small" integer uniquely associated with o in this.
requires: o is a member of the set of objects indexed by this
effects: returns the integer uniquely associated with o from a densely-packed, non-negative set of integers whose smallest element is close to zero.

implementsReverseMapping

public boolean implementsReverseMapping()
Tells user whether this particular Indexer implements the getByID() method.
Copyright © 2003 C. Scott Ananian