## edu.stanford.nlp.util
Interface Index<E>

Type Parameters:
  `E` -

All Superinterfaces:
  Iterable<E>, Serializable

All Known Implementing Classes:
  HashIndex

    public interface Index<E>

extends Iterable<E>, Serializable

Minimalist interface for implementations of Index. This interface should allow Index and OAIndex to be used interchangeably in certain contexts. Originally extracted from util.Index on 3/13/2007

Author:
  Daniel Cer

Method Summary
`boolean` `add(E e)`
`boolean` `addAll(Collection<? extends E> c)`
`void` `clear()`
`boolean` `contains(Object o)`
`E` `get(int i)` Gets the object whose index is the integer argument.
`int` `indexOf(E o)` Returns the integer index of the Object in the Index or -1 if the Object is not already in the Index.
`int` `indexOf(E o, boolean add)` Takes an Object and returns the integer index of the Object, perhaps adding it to the index first.
`boolean` `isLocked()` Queries the Index for whether it's locked or not.
`void` `lock()` Locks the Index.
`Collection<E>` `objects(int[] indices)` Looks up the objects corresponding to an array of indices, and returns them in a `Collection`.
`List<E>` `objectsList()` Returns a complete `List` of indexed objects, in the order of their indices.
`boolean` `remove(Object o)`
`void` `saveToFilename(String s)` Save the contents of this index into a file.
`void` `saveToWriter(Writer out)` Save the contents of this index into string form, as part of a larger text-serialization.
`int` `size()` Returns the number of indexed objects.

`

`<T> T[]`

`

`toArray(T[] a)`

`void` `unlock()` Unlocks the Index.

Methods inherited from interface java.lang.Iterable
`iterator`

Method Detail

### size

    int size()

  Returns the number of indexed objects.

  Returns:
    the number of indexed objects.

### get

    E get(int i)

  Gets the object whose index is the integer argument.

  Parameters:
    `i` - the integer index to be queried for the corresponding argument
  Returns:
    the object whose index is the integer argument.

### indexOf

    int indexOf(E o)

  Returns the integer index of the Object in the Index or -1 if the Object is not already in the Index.

  Parameters:
    `o` - the Object whose index is desired.
  Returns:
    the index of the Object argument. Returns -1 if the object is not in the index.

### indexOf

    int indexOf(E o,
                boolean add)

  Takes an Object and returns the integer index of the Object, perhaps adding it to the index first. Returns -1 if the Object is not in the Index. (Note: indexOf(x, true) is the direct replacement for the number(x) method in the old Numberer class.)

  Parameters:
    `o` - the Object whose index is desired.
    `add` - Whether it is okay to add new items to the index
  Returns:
    the index of the Object argument. Returns -1 if the object is not in the index.

### objectsList

    List<E> objectsList()

  Returns a complete `List` of indexed objects, in the order of their indices.

  Returns:
    a complete `List` of indexed objects

### objects

    Collection<E> objects(int[] indices)

  Looks up the objects corresponding to an array of indices, and returns them in a `Collection`.

  Parameters:
    `indices` - An array of indices
  Returns:
    a `Collection` of the objects corresponding to the indices argument.

### isLocked

    boolean isLocked()

  Queries the Index for whether it's locked or not.

  Returns:
    whether or not the Index is locked

### lock

    void lock()

  Locks the Index. A locked index cannot have new elements added to it (calls to `add(E)` will leave the Index unchanged and return `false`).

### unlock

    void unlock()

  Unlocks the Index. A locked index cannot have new elements added to it (calls to `add(E)` will leave the Index unchanged and return `false`).

### saveToWriter

    void saveToWriter(Writer out)
                      throws IOException

  Save the contents of this index into string form, as part of a larger text-serialization.

  Parameters:
    `out` - Writer to save to.
  Throws:
    `IOException` - Exception thrown if cannot save.

### saveToFilename

    void saveToFilename(String s)

  Save the contents of this index into a file.

  Parameters:
    `s` - File name.

### contains

    boolean contains(Object o)

### toArray

    <T> T[] toArray(T[] a)

### add

    boolean add(E e)

### remove

    boolean remove(Object o)

### addAll

    boolean addAll(Collection<? extends E> c)

### clear

    void clear()

Stanford NLP Group