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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • t2imap

      private final it.unimi.dsi.fastutil.objects.Object2IntMap<T> t2imap
      Integer value for every object.
    • i2tmap

      private final java.util.List<T> i2tmap
      Object for each integer value.
    • numObjects

      private int numObjects
      Number of objects.
  • Constructor Details

  • Method Details

    • containsObject

      public boolean containsObject​(T i)
      Description copied from interface: Index
      Checks whether the index contains a given object.
      Specified by:
      containsObject in interface Index<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 interface Index<T>
      Returns:
      the number of objects in the index.
    • getAllObjects

      public java.util.stream.Stream<T> getAllObjects()
      Description copied from interface: Index
      A stream of all the objects in the index.
      Specified by:
      getAllObjects in interface Index<T>
      Returns:
      the stream.
    • object2idx

      public int object2idx​(T i)
      Description copied from interface: ReducedIndex
      Gets the index of a given object.
      Specified by:
      object2idx in interface ReducedIndex<T>
      Parameters:
      i - Object to obtain.
      Returns:
      the index if the object exists, -1 if not.
    • idx2object

      public T idx2object​(int idx)
      Description copied from interface: ReducedIndex
      Gets the object corresponding to a certain index.
      Specified by:
      idx2object in interface ReducedIndex<T>
      Parameters:
      idx - The index.
      Returns:
      the object corresponding to the index.
    • addObject

      public int addObject​(T t)
      Description copied from interface: Index
      Adds an object to the index.
      Specified by:
      addObject in interface Index<T>
      Parameters:
      t - Object to add.
      Returns:
      the index of the added object.
    • removeObject

      public int removeObject​(T t)
      Description copied from interface: Index
      Removes an object from the index.
      Specified by:
      removeObject in interface Index<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 interface Index<T>
      Returns:
      all ids.