com.ibm.wala.util.intset
Class OffsetOrdinalSetMapping<T>

java.lang.Object
  extended by com.ibm.wala.util.intset.OffsetOrdinalSetMapping<T>
All Implemented Interfaces:
OrdinalSetMapping<T>, java.lang.Iterable<T>

public class OffsetOrdinalSetMapping<T>
extends java.lang.Object
implements OrdinalSetMapping<T>

An ordinal set mapping, backed a delegate, but adding an offset to each index.


Method Summary
 int add(T o)
          Add an Object to the set of mapped objects.
 int getMappedIndex(T o)
           
 T getMappedObject(int n)
           
 int getMappingSize()
           
 boolean hasMappedIndex(T o)
           
 java.util.Iterator<T> iterator()
           
static
<T> OffsetOrdinalSetMapping<T>
make(OrdinalSetMapping<T> delegate, int offset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

make

public static <T> OffsetOrdinalSetMapping<T> make(OrdinalSetMapping<T> delegate,
                                                  int offset)

add

public int add(T o)
Description copied from interface: OrdinalSetMapping
Add an Object to the set of mapped objects.

Specified by:
add in interface OrdinalSetMapping<T>
Returns:
the integer to which the object is mapped.

getMappedIndex

public int getMappedIndex(T o)
Specified by:
getMappedIndex in interface OrdinalSetMapping<T>
Returns:
the number of a given object, or -1 if the object is not currently in the range.

getMappedObject

public T getMappedObject(int n)
                  throws java.util.NoSuchElementException
Specified by:
getMappedObject in interface OrdinalSetMapping<T>
Returns:
the object numbered n.
Throws:
java.util.NoSuchElementException

getMappingSize

public int getMappingSize()
Specified by:
getMappingSize in interface OrdinalSetMapping<T>
Returns:
the size of the domain of the bijection.

hasMappedIndex

public boolean hasMappedIndex(T o)
Specified by:
hasMappedIndex in interface OrdinalSetMapping<T>
Returns:
whether the given object is mapped by this mapping

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>