E
- The type of objects which are interned by this interner.public class Interner<E> extends Object implements Serializable, Cloneable
Constructor and Description |
---|
Interner()
Creates an empty interner.
|
Modifier and Type | Method and Description |
---|---|
int |
addObject(E object)
Add an object to the interner.
|
int |
addObjectWithIndex(int index,
E object)
Adds an object to the interner with a specific numeric ID.
|
void |
clear()
Removes all mappings from this interner.
|
Object |
clone() |
IntSet |
getKnownIds()
Returns the set of known numeric IDs.
|
Set<E> |
getKnownObjects()
Returns the set of all known objects.
|
SignatureMapper |
getMapperTo(Interner<E> other)
Creates an object that maps back and forth between the
numeric IDs in this interner and those in another interner.
|
int |
getNextIndex()
Returns the numeric ID that will be assigned
to the next object.
|
Map<E,Integer> |
getSymbolTable()
Returns a map from the objects known to the interner to the ids
by which the objects are known.
|
boolean |
isKnownObject(E object)
Checks whether the object is known.
|
boolean |
isTrustingMode()
Returns whether the interner is currently in trusting mode, meaing it assumes
that there will be no attempts to add the same object twice.
|
E |
normalize(E object)
Returns an object that is equals to "object"
and identical to an object in the interner.
|
int[] |
remap(Interner<E> other)
Returns an arrary x such that the symbol
i in this interner is the same as the symbol
x[i] in the other interner.
|
E |
resolveId(int index)
Retrieves the object for the given numeric ID.
|
Iterable<E> |
resolveIds(Collection<Integer> indices)
Returns an iterable over the objects corresponding
to the given collection of numeric IDs.
|
int |
resolveObject(E object)
Retrieves the numeric ID of the given object.
|
void |
retainOnly(IntSet retainedIds)
This removes from the interner all the objects that do not corresponds to ids
in this given set.
|
void |
setTrustingMode(boolean trustingMode)
Switches the interner to "trusting mode".
|
String |
toString() |
public SignatureMapper getMapperTo(Interner<E> other)
other
- public void clear()
public int addObject(E object)
setTrustingMode(boolean)
)
to skip the exists-check for improved efficiency.object
- public int addObjectWithIndex(int index, E object)
index
- object
- public int resolveObject(E object)
object
- public E resolveId(int index)
index
- public Iterable<E> resolveIds(Collection<Integer> indices)
indices
- public boolean isKnownObject(E object)
object
- public E normalize(E object)
object
- public IntSet getKnownIds()
public int getNextIndex()
public Map<E,Integer> getSymbolTable()
public int[] remap(Interner<E> other)
other
- public void retainOnly(IntSet retainedIds)
retainedIds
- public boolean isTrustingMode()
public void setTrustingMode(boolean trustingMode)
trustingMode
- Copyright © 2017. All rights reserved.