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

java.lang.Object
  extended by com.ibm.wala.util.intset.MutableMapping<T>
All Implemented Interfaces:
OrdinalSetMapping<T>, java.lang.Iterable<T>
Direct Known Subclasses:
UnorderedDomain

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

A bit set mapping based on an object array. This is not terribly efficient, but is useful for prototyping.


Constructor Summary
MutableMapping()
          Constructor MutableMapping.
MutableMapping(java.lang.Object[] array)
          Constructor for MutableMapping.
 
Method Summary
 int add(T o)
          Add an Object to the set of mapped objects.
 void deleteMappedObject(java.lang.Object n)
           
 int getMappedIndex(java.lang.Object o)
           
 T getMappedObject(int n)
           
 int getMappingSize()
           
 java.util.Collection<T> getObjects()
           
 boolean hasMappedIndex(java.lang.Object o)
           
 java.util.Iterator<T> iterator()
           
 OrdinalSet<T> makeSingleton(int i)
           
 void put(int i, T o)
          Add an object to the set of mapped objects at index i.
 void replace(T a, T b)
          Replace a in this mapping with b.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MutableMapping

public MutableMapping(java.lang.Object[] array)
Constructor for MutableMapping.

Throws:
java.lang.IllegalArgumentException - if array is null

MutableMapping

public MutableMapping()
Constructor MutableMapping.

Method Detail

getMappedObject

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

getMappedIndex

public int getMappedIndex(java.lang.Object 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.

hasMappedIndex

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

getMappingSize

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

add

public int add(T o)
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.

toString

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

iterator

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

makeSingleton

public OrdinalSet<T> makeSingleton(int i)

deleteMappedObject

public void deleteMappedObject(java.lang.Object n)
Parameters:
n -

getObjects

public java.util.Collection<T> getObjects()

replace

public void replace(T a,
                    T b)
             throws java.lang.IllegalArgumentException
Replace a in this mapping with b.

Throws:
java.lang.IllegalArgumentException

put

public void put(int i,
                T o)
Add an object to the set of mapped objects at index i.