## org.biojava.bio.symbol
Interface AlphabetIndex

All Superinterfaces:
  Changeable

    public interface AlphabetIndex

extends Changeable

Map between Symbols and index numbers.

The Symbols will all come from a single finite alphabet. The indices will range from 0 to getAlphabet().size()-1 inclusive with each symbol having a unique index. The resulting table can be used to look up array indices by symbol, which in many cases will be more efficient than performing a Map operation on, for example, a HashMap.

An index should do whatever is necessary to stay synchronized with its alphabet. It may chose to modify the index table with the alphabet, or to veto all changes to the alphabet that would invalidate the indexing scheme.

Since:
  1.1
Author:
  Thomas Down, Matthew pocock

Field Summary
`static ChangeType` `INDEX` Indicates that the index is changing, probably due to the underlying alphabet changing.

Method Summary
`FiniteAlphabet` `getAlphabet()` Retrieve the alphabet that this indexes.
`int` `indexForSymbol(Symbol s)` Return the unique index for a symbol.
`Symbol` `symbolForIndex(int i)` Retrieve the symbol for an index.

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

Field Detail

### INDEX

    static final ChangeType INDEX

  Indicates that the index is changing, probably due to the underlying alphabet changing.

  The previous & changed fields should be arrays of symbols in the order they are indexed in the unmodified and modified indices respectively.

Method Detail

### getAlphabet

    FiniteAlphabet getAlphabet()

  Retrieve the alphabet that this indexes.

  Returns:
    the FiniteAlphabet that is indexed by this object

### indexForSymbol

    int indexForSymbol(Symbol s)
                       throws IllegalSymbolException

  Return the unique index for a symbol.

  Parameters:
    `s` - the Symbol to index
  Returns:
    the unique index for the symbol
  Throws:
    `IllegalSymbolException` - if s is not a member of the indexed alphabet, or if the indexer only indexes the AtomicSymbols within an alphabet and s was not attomic.

### symbolForIndex

    Symbol symbolForIndex(int i)
                          throws IndexOutOfBoundsException

  Retrieve the symbol for an index.

  Parameters:
    `i` - the index of the symbol
  Returns:
    the symbol at that index
  Throws:
    `IndexOutOfBoundsException` - if i is negative or >= getAlphabet().size()