Package es.uam.eps.ir.relison.index.fast
Class FastIndex<T>
java.lang.Object
es.uam.eps.ir.relison.index.fast.FastIndex<T>
- Type Parameters:
T
- Type of the objects.
- All Implemented Interfaces:
Index<T>
,ReducedIndex<T>
public class FastIndex<T> extends java.lang.Object implements Index<T>
Fast implementation of a generic index.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<T>
i2tmap
Object for each integer value.private int
numObjects
Number of objects.private it.unimi.dsi.fastutil.objects.Object2IntMap<T>
t2imap
Integer value for every object. -
Constructor Summary
Constructors Constructor Description FastIndex()
Constructor. -
Method Summary
Modifier and Type Method Description int
addObject(T t)
Adds an object to the index.boolean
containsObject(T i)
Checks whether the index contains a given object.java.util.stream.Stream<T>
getAllObjects()
A stream of all the objects in the index.java.util.stream.IntStream
getAllObjectsIds()
A stream of all ids.T
idx2object(int idx)
Gets the object corresponding to a certain index.int
numObjects()
Index size.int
object2idx(T i)
Gets the index of a given object.int
removeObject(T t)
Removes an object from the index.
-
Field Details
-
t2imap
Integer value for every object. -
i2tmap
Object for each integer value. -
numObjects
private int numObjectsNumber of objects.
-
-
Constructor Details
-
FastIndex
public FastIndex()Constructor.
-
-
Method Details
-
containsObject
Description copied from interface:Index
Checks whether the index contains a given object.- Specified by:
containsObject
in interfaceIndex<T>
- Parameters:
i
- The object to check.- Returns:
- true if the index contains the object, false if not.
-
numObjects
public int numObjects()Description copied from interface:Index
Index size.- Specified by:
numObjects
in interfaceIndex<T>
- Returns:
- the number of objects in the index.
-
getAllObjects
Description copied from interface:Index
A stream of all the objects in the index.- Specified by:
getAllObjects
in interfaceIndex<T>
- Returns:
- the stream.
-
object2idx
Description copied from interface:ReducedIndex
Gets the index of a given object.- Specified by:
object2idx
in interfaceReducedIndex<T>
- Parameters:
i
- Object to obtain.- Returns:
- the index if the object exists, -1 if not.
-
idx2object
Description copied from interface:ReducedIndex
Gets the object corresponding to a certain index.- Specified by:
idx2object
in interfaceReducedIndex<T>
- Parameters:
idx
- The index.- Returns:
- the object corresponding to the index.
-
addObject
Description copied from interface:Index
Adds an object to the index. -
removeObject
Description copied from interface:Index
Removes an object from the index.- Specified by:
removeObject
in interfaceIndex<T>
- Parameters:
t
- The object to remove.- Returns:
- the index of the removed object, -1 if it did not exist.
-
getAllObjectsIds
public java.util.stream.IntStream getAllObjectsIds()Description copied from interface:Index
A stream of all ids.- Specified by:
getAllObjectsIds
in interfaceIndex<T>
- Returns:
- all ids.
-