Package com.ibm.wala.util.intset
Class MutableMapping<T>
- java.lang.Object
-
- com.ibm.wala.util.intset.MutableMapping<T>
-
- All Implemented Interfaces:
OrdinalSetMapping<T>
,java.io.Serializable
,java.lang.Iterable<T>
public class MutableMapping<T> extends java.lang.Object implements OrdinalSetMapping<T>, java.io.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(java.lang.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(java.lang.Object o)
T
getMappedObject(int n)
int
getMaximumIndex()
java.util.Collection<T>
getObjects()
int
getSize()
boolean
hasMappedIndex(T o)
java.util.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.java.lang.String
toString()
-
-
-
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(java.lang.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.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
makeSingleton
public OrdinalSet<T> makeSingleton(int i)
-
deleteMappedObject
public void deleteMappedObject(T 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.
-
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
-
-