Package net.automatalib.alphabet
Interface Alphabet<I>
-
- Type Parameters:
I
- symbol type
- All Superinterfaces:
ArrayWritable<I>
,Collection<I>
,Comparator<I>
,IntFunction<I>
,Iterable<I>
,ToIntFunction<I>
- All Known Subinterfaces:
GrowingAlphabet<I>
,ProceduralInputAlphabet<I>
,ProceduralOutputAlphabet<O>
,VPAlphabet<I>
public interface Alphabet<I> extends ArrayWritable<I>, Collection<I>, Comparator<I>, IntFunction<I>, ToIntFunction<I>
Class implementing an (indexed) alphabet. An alphabet is a collection of symbols, where each symbol has a (unique) index. Apart from serving as a collection, this class also provides a one-to-one mapping between symbols and indices.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default I
apply(int index)
default int
applyAsInt(I symbol)
default int
compare(I o1, I o2)
default boolean
containsSymbol(I symbol)
Checks whether the given symbol is part of the alphabet.I
getSymbol(int index)
Returns the symbol with the given index in this alphabet.int
getSymbolIndex(I symbol)
Returns the index of the given symbol in the alphabet.default <I2> Mapping<I2,I>
translateFrom(Alphabet<I2> other)
default void
writeToArray(int offset, @Nullable Object[] array, int tgtOfs, int num)
-
Methods inherited from interface net.automatalib.common.smartcollection.ArrayWritable
size
-
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Method Detail
-
apply
default I apply(int index)
- Specified by:
apply
in interfaceIntFunction<I>
-
getSymbol
I getSymbol(int index)
Returns the symbol with the given index in this alphabet.- Parameters:
index
- the index of the requested symbol.- Returns:
- symbol with the given index.
- Throws:
IllegalArgumentException
- if there is no symbol with this index.
-
applyAsInt
default int applyAsInt(I symbol)
- Specified by:
applyAsInt
in interfaceToIntFunction<I>
-
getSymbolIndex
int getSymbolIndex(I symbol)
Returns the index of the given symbol in the alphabet.- Parameters:
symbol
- the symbol whose index should be determined- Returns:
- the index of the given symbol
- Throws:
IllegalArgumentException
- if the provided symbol does not belong to the alphabet.
-
compare
default int compare(I o1, I o2)
- Specified by:
compare
in interfaceComparator<I>
-
writeToArray
default void writeToArray(int offset, @Nullable Object[] array, int tgtOfs, int num)
- Specified by:
writeToArray
in interfaceArrayWritable<I>
-
containsSymbol
default boolean containsSymbol(I symbol)
Checks whether the given symbol is part of the alphabet.Caution: the default implementation is rather inefficient and should be overridden, if possible.
- Parameters:
symbol
- the symbol to check- Returns:
true
iff the symbol is part of the alphabet
-
-