Package com.ibm.wala.util.intset
Class MutableMapping<T>
- java.lang.Object
-
- com.ibm.wala.util.intset.MutableMapping<T>
-
- All Implemented Interfaces:
OrdinalSetMapping<T>
,Serializable
,Iterable<T>
- Direct Known Subclasses:
UnorderedDomain
public class MutableMapping<T> extends Object implements OrdinalSetMapping<T>, Serializable
A bit set mapping based on an object array. This is not terribly efficient, but is useful for prototyping.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MutableMapping()
MutableMapping(Object[] array)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
add(T o)
Add an object to the set of mapped objects.void
deleteMappedObject(T n)
int
getMappedIndex(Object o)
T
getMappedObject(int n)
int
getMaximumIndex()
Collection<T>
getObjects()
int
getSize()
boolean
hasMappedIndex(T o)
Iterator<T>
iterator()
static <T> MutableMapping<T>
make()
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.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
MutableMapping
public MutableMapping(Object[] array)
- Throws:
IllegalArgumentException
- if array is null
-
MutableMapping
protected MutableMapping()
-
-
Method Detail
-
make
public static <T> MutableMapping<T> make()
-
getMappedObject
public T getMappedObject(int n)
- Specified by:
getMappedObject
in interfaceOrdinalSetMapping<T>
- Returns:
- the object numbered n.
-
getMappedIndex
public int getMappedIndex(Object o)
- Specified by:
getMappedIndex
in interfaceOrdinalSetMapping<T>
- Returns:
- the number of a given object, or -1 if the object is not currently in the range.
-
hasMappedIndex
public boolean hasMappedIndex(T o)
- Specified by:
hasMappedIndex
in interfaceOrdinalSetMapping<T>
- Returns:
- whether the given object is mapped by this mapping
-
add
public int add(T o)
Add an object to the set of mapped objects.- Specified by:
add
in interfaceOrdinalSetMapping<T>
- Returns:
- the integer to which the object is mapped.
-
makeSingleton
public OrdinalSet<T> makeSingleton(int i)
-
deleteMappedObject
public void deleteMappedObject(T n)
- Parameters:
n
-
-
getObjects
public Collection<T> getObjects()
-
replace
public void replace(T a, T b) throws IllegalArgumentException
Replace a in this mapping with b.- Throws:
IllegalArgumentException
-
put
public void put(int i, T o)
Add an object to the set of mapped objects at index i.
-
getMaximumIndex
public int getMaximumIndex()
- Specified by:
getMaximumIndex
in interfaceOrdinalSetMapping<T>
- Returns:
- the maximum integer mapped to an object
-
getSize
public int getSize()
- Specified by:
getSize
in interfaceOrdinalSetMapping<T>
- Returns:
- the current size of the bijection
-
-