Class Indexer<E extends Comparable<E>>

java.lang.Object
edu.berkeley.nlp.lm.collections.Indexer<E>
All Implemented Interfaces:
Serializable

public class Indexer<E extends Comparable<E>> extends Object implements Serializable
Maintains a two-way map between a set of objects and contiguous integers from 0 to the number of objects.
Author:
Dan Klein, Adam Pauls
See Also:
  • Field Details

  • Constructor Details

    • Indexer

      public Indexer(boolean sync)
    • Indexer

      public Indexer()
    • Indexer

      public Indexer(Collection<? extends E> c)
  • Method Details

    • lock

      public void lock()
    • getObject

      public E getObject(int index)
    • add

      public boolean add(E elem)
    • size

      public int size()
      Returns the number of objects indexed.
    • indexOf

      public int indexOf(E o)
      Returns the index of the given object, or -1 if the object is not present in the indexer.
      Parameters:
      o -
      Returns:
    • getIndex

      public int getIndex(E e)
      Return the index of the element If doesn't exist, add it.
    • trim

      public void trim()
      Save some space my compacting underlying maps and lists.
    • getObjects

      public Iterable<E> getObjects()