Package com.ibm.wala.util.collections
Class ObjectArrayMapping<T>
- java.lang.Object
-
- com.ibm.wala.util.collections.ObjectArrayMapping<T>
-
- All Implemented Interfaces:
OrdinalSetMapping<T>,Iterable<T>
public class ObjectArrayMapping<T> extends Object implements OrdinalSetMapping<T>
A bit set mapping based on an immutable object array. This is not terribly efficient, but is useful for prototyping.
-
-
Constructor Summary
Constructors Constructor Description ObjectArrayMapping(T[] array)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intadd(Object o)Add an Object to the set of mapped objects.intgetMappedIndex(@Nullable Object o)TgetMappedObject(int n)intgetMaximumIndex()intgetSize()booleanhasMappedIndex(Object o)Iterator<T>iterator()Stream<T>stream()Stream over mapped objects.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ObjectArrayMapping
public ObjectArrayMapping(T[] array)
-
-
Method Detail
-
getMappedObject
public T getMappedObject(int n) throws NoSuchElementException
- Specified by:
getMappedObjectin interfaceOrdinalSetMapping<T>- Returns:
- the object numbered n.
- Throws:
NoSuchElementException
-
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(Object o)
- Specified by:
hasMappedIndexin interfaceOrdinalSetMapping<T>- Returns:
- whether the given object is mapped by this mapping
-
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
-
add
public int add(Object o) throws UnimplementedError
Description copied from interface:OrdinalSetMappingAdd an Object to the set of mapped objects.- Specified by:
addin interfaceOrdinalSetMapping<T>- Returns:
- the integer to which the object is mapped.
- Throws:
UnimplementedError
-
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
-
-