edu.harvard.seas.iis.util.collections
Class ReverseIndex

java.lang.Object
  extended by edu.harvard.seas.iis.util.collections.ReverseIndex

public class ReverseIndex
extends java.lang.Object

Author:
kgajos A reverse index for an array of objects -- given an array it builds a reverse mapping that lets you lookup the object's position within the array. At the moment it is assumed that objects are unique within each array. The objects have to implement hashCode() and equals()

Constructor Summary
ReverseIndex(java.lang.Object[] in)
           
 
Method Summary
 int getLocation(java.lang.Object o)
          Returns the location of the given object in the original array;
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReverseIndex

public ReverseIndex(java.lang.Object[] in)
Method Detail

getLocation

public int getLocation(java.lang.Object o)
Returns the location of the given object in the original array;

Parameters:
o - object to be looked up
Returns:
its position in the original array or -1 if not found