Package net.automatalib.alphabet
Class FastAlphabet<I extends MutableNumericID>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<T>
-
- net.automatalib.common.util.nid.DynamicList<I>
-
- net.automatalib.alphabet.FastAlphabet<I>
-
- Type Parameters:
I
- input symbol class.
- All Implemented Interfaces:
Iterable<I>
,Collection<I>
,Comparator<I>
,IntFunction<I>
,ToIntFunction<I>
,List<I>
,Alphabet<I>
,GrowingAlphabet<I>
,ArrayWritable<I>
public class FastAlphabet<I extends MutableNumericID> extends DynamicList<I> implements GrowingAlphabet<I>
A fast alphabet implementation, that assumes identifiers are stored directly in the input symbols.
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description FastAlphabet()
FastAlphabet(I... symbols)
FastAlphabet(List<? extends I> symbols)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addSymbol(I a)
Adds a new symbol to the alphabet.int
compare(I o1, I o2)
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.FastAlphabet<I>
reversed()
-
Methods inherited from class net.automatalib.common.util.nid.DynamicList
add, clear, get, isEmpty, iterator, remove, remove, remove, safeGet, size, swap, writeToArray
-
Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.automatalib.alphabet.Alphabet
apply, applyAsInt, translateFrom, writeToArray
-
Methods inherited from interface net.automatalib.common.smartcollection.ArrayWritable
size
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
-
Methods inherited from interface java.util.Comparator
equals, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface java.util.List
addAll, contains, containsAll, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Constructor Detail
-
FastAlphabet
public FastAlphabet()
-
FastAlphabet
@SafeVarargs public FastAlphabet(I... symbols)
-
-
Method Detail
-
addSymbol
public int addSymbol(I a)
Description copied from interface:GrowingAlphabet
Adds a new symbol to the alphabet. Some alphabets may prevent symbols from being added twice. In this case, the original alphabet remains unchanged, but this is not considered an error.- Specified by:
addSymbol
in interfaceGrowingAlphabet<I extends MutableNumericID>
- Returns:
- the index of the symbol in the alphabet, after adding it.
-
getSymbol
public I getSymbol(int index)
Description copied from interface:Alphabet
Returns the symbol with the given index in this alphabet.- Specified by:
getSymbol
in interfaceAlphabet<I extends MutableNumericID>
- Parameters:
index
- the index of the requested symbol.- Returns:
- symbol with the given index.
-
getSymbolIndex
public int getSymbolIndex(I symbol)
Description copied from interface:Alphabet
Returns the index of the given symbol in the alphabet.- Specified by:
getSymbolIndex
in interfaceAlphabet<I extends MutableNumericID>
- Parameters:
symbol
- the symbol whose index should be determined- Returns:
- the index of the given symbol
-
compare
public int compare(I o1, I o2)
- Specified by:
compare
in interfaceAlphabet<I extends MutableNumericID>
- Specified by:
compare
in interfaceComparator<I extends MutableNumericID>
-
containsSymbol
public boolean containsSymbol(I symbol)
Description copied from interface:Alphabet
Checks whether the given symbol is part of the alphabet.Caution: the default implementation is rather inefficient and should be overridden, if possible.
- Specified by:
containsSymbol
in interfaceAlphabet<I extends MutableNumericID>
- Parameters:
symbol
- the symbol to check- Returns:
true
iff the symbol is part of the alphabet
-
reversed
public FastAlphabet<I> reversed()
- Specified by:
reversed
in interfaceComparator<I extends MutableNumericID>
-
-