mark.core.util
Class ObjectMap

java.lang.Object
  |
  +--mark.core.util.ObjectMap

public class ObjectMap
extends java.lang.Object

An ObjectMap associates each object in a set of objects with a unique integer in the range 0..numObjects - 1.


Constructor Summary
ObjectMap()
          Initializes the map.
ObjectMap(java.util.Collection objects)
          Initializes the map and associates the given objects.
ObjectMap(java.lang.Object[] objects)
          Initializes the map and associates the given objects.
ObjectMap(ObjectMap objects)
          Initializes the map and associates the given objects.
 
Method Summary
 void add(java.lang.Object o)
          If a mapping for the given object does not exist, adds one.
 java.lang.Object map(int i)
          Given an integer, returns the corresponding object.
 int map(java.lang.Object o)
          Given an object, returns the corresponding integer.
 int size()
          returns the number of mappings.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectMap

public ObjectMap()
Initializes the map.


ObjectMap

public ObjectMap(java.lang.Object[] objects)
Initializes the map and associates the given objects.

Parameters:
objects - the objects to associate.

ObjectMap

public ObjectMap(java.util.Collection objects)
Initializes the map and associates the given objects.

Parameters:
objects - the objects to associate.

ObjectMap

public ObjectMap(ObjectMap objects)
Initializes the map and associates the given objects.

Parameters:
objects - the objects to associate.
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

add

public void add(java.lang.Object o)
If a mapping for the given object does not exist, adds one.

Parameters:
o - the new object.

map

public java.lang.Object map(int i)
Given an integer, returns the corresponding object.

Parameters:
i - the integer.
Returns:
the corresponding object.

map

public int map(java.lang.Object o)
Given an object, returns the corresponding integer. If the object is not mapped, then returns -1.

Parameters:
o - the object.
Returns:
the corresponding integer or -1 if the mapping does not exist.

size

public int size()
returns the number of mappings.