- All Superinterfaces:
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.
- Thomas Down, Matthew pocock
All Methods Instance Methods Abstract Methods Modifier and Type Method Description
getAlphabet()Retrieve the alphabet that this indexes.
indexForSymbol(Symbol s)Return the unique index for a symbol.
symbolForIndex(int i)Retrieve the symbol for an index.
getAlphabetRetrieve the alphabet that this indexes.
- the FiniteAlphabet that is indexed by this object
int indexForSymbol(Symbol s) throws IllegalSymbolExceptionReturn the unique index for a symbol.
s- the Symbol to index
- the unique index for the symbol
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.