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>
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 protectedMutableMapping()MutableMapping(Object[] array)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intadd(T o)Add an object to the set of mapped objects.voiddeleteMappedObject(T n)intgetMappedIndex(@Nullable Object o)TgetMappedObject(int n)intgetMaximumIndex()Collection<T>getObjects()intgetSize()booleanhasMappedIndex(T o)Iterator<T>iterator()static <T> MutableMapping<T>make()OrdinalSet<T>makeSingleton(int i)voidput(int i, T o)Add an object to the set of mapped objects at index i.voidreplace(T a, T b)Replace a in this mapping with b.Stream<T>stream()Stream over mapped objects.StringtoString()-
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:
getMappedObjectin interfaceOrdinalSetMapping<T>- Returns:
- the object numbered n.
-
getMappedIndex
public int getMappedIndex(@Nullable Object o)
- Specified by:
getMappedIndexin 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:
hasMappedIndexin 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:
addin interfaceOrdinalSetMapping<T>- Returns:
- the integer to which the object is mapped.
-
iterator
public Iterator<T> iterator()
- Specified by:
iteratorin interfaceIterable<T>- See Also:
Iterable.iterator()
-
stream
public Stream<T> stream()
Description copied from interface:OrdinalSetMappingStream over mapped objects.- Specified by:
streamin interfaceOrdinalSetMapping<T>- Returns:
- a stream over the mapped objects
-
makeSingleton
public OrdinalSet<T> makeSingleton(int i)
- See Also:
SparseIntSet.singleton(int)
-
deleteMappedObject
public void deleteMappedObject(T 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:
getMaximumIndexin interfaceOrdinalSetMapping<T>- Returns:
- the maximum integer mapped to an object
-
getSize
public int getSize()
- Specified by:
getSizein interfaceOrdinalSetMapping<T>- Returns:
- the current size of the bijection
-
-