Package net.automatalib.alphabet
Class ArrayAlphabet<I>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<I>
-
- net.automatalib.alphabet.AbstractAlphabet<I>
-
- net.automatalib.alphabet.ArrayAlphabet<I>
-
- All Implemented Interfaces:
Iterable<I>
,Collection<I>
,Comparator<I>
,IntFunction<I>
,ToIntFunction<I>
,List<I>
,Alphabet<I>
,ArrayWritable<I>
- Direct Known Subclasses:
EnumAlphabet
public class ArrayAlphabet<I> extends AbstractAlphabet<I>
-
-
Field Summary
Fields Modifier and Type Field Description protected I[]
symbols
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description ArrayAlphabet(I... symbols)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.int
size()
The size of this container.void
writeToArray(int offset, @Nullable Object[] array, int tgtOfs, int num)
Writes the contents of this container to an array.-
Methods inherited from class net.automatalib.alphabet.AbstractAlphabet
get, reversed
-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, 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, compare, translateFrom
-
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, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Field Detail
-
symbols
protected final I[] symbols
-
-
Constructor Detail
-
ArrayAlphabet
@SafeVarargs public ArrayAlphabet(I... symbols)
-
-
Method Detail
-
getSymbol
public I getSymbol(int index)
Description copied from interface:Alphabet
Returns the symbol with the given index in this alphabet.- 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.- Parameters:
symbol
- the symbol whose index should be determined- Returns:
- the index of the given symbol
-
writeToArray
public void writeToArray(int offset, @Nullable Object[] array, int tgtOfs, int num)
Description copied from interface:ArrayWritable
Writes the contents of this container to an array. The behavior of calling this method should be equivalent toSystem.arraycopy(this.toArray(), offset, array, tgtOfs, num);
- Parameters:
offset
- how many elements of this container to skip.array
- the array in which to store the elements.tgtOfs
- the starting offset in the target array.num
- the maximum number of elements to copy.
-
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.
- Parameters:
symbol
- the symbol to check- Returns:
true
iff the symbol is part of the alphabet
-
size
public int size()
Description copied from interface:ArrayWritable
The size of this container.- Specified by:
size
in interfaceArrayWritable<I>
- Specified by:
size
in interfaceCollection<I>
- Specified by:
size
in interfaceList<I>
- Specified by:
size
in classAbstractCollection<I>
-
-