Class GenericIndex<T>

java.lang.Object
es.uam.eps.ir.relison.index.GenericIndex<T>
Type Parameters:
T - Type of the element.
All Implemented Interfaces:
java.io.Serializable

public class GenericIndex<T>
extends java.lang.Object
implements java.io.Serializable
Bi-map-like structure to back fast version of indexes. It keeps to maps: id-to-index and index-to-id. Value of indexes go from 0 (included) to the number of elements (excluded).
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.util.List<T> i2tmap
    Object for each integer value.
    private it.unimi.dsi.fastutil.objects.Object2IntMap<T> t2imap
    Integer value for every object.
  • Constructor Summary

    Constructors 
    Constructor Description
    GenericIndex()
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    int add​(T t)
    Adds an element to the structure, if it is not in the
    boolean containsId​(T t)
    Checks if the corresponding object is included in the index.
    java.util.stream.Stream<T> getIds()
    Gets a stream of objects in the index
    int getIdx​(T t)
    Gets the index of the object.
    T getObject​(int idx)
    Gets the object corresponding to the given index.
    int size()
    Gets the size of 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.
  • Constructor Details

  • Method Details

    • add

      public int add​(T t)
      Adds an element to the structure, if it is not in the
      Parameters:
      t - The element to add.
      Returns:
      the index for the corresponding element.
    • getIdx

      public int getIdx​(T t)
      Gets the index of the object.
      Parameters:
      t - The object.
      Returns:
      the index of the object if it exists, -1 if not.
    • getObject

      public T getObject​(int idx)
      Gets the object corresponding to the given index.
      Parameters:
      idx - The index.
      Returns:
      the object in that index.
    • containsId

      public boolean containsId​(T t)
      Checks if the corresponding object is included in the index.
      Parameters:
      t - The object.
      Returns:
      true if it exists, false if not.
    • size

      public int size()
      Gets the size of the index,
      Returns:
      the size of the index.
    • getIds

      public java.util.stream.Stream<T> getIds()
      Gets a stream of objects in the index
      Returns:
      the stream.