I - input symbol typeT - transition typeSP - state property typeTP - transition property typepublic abstract class AbstractCompact<I,T,SP,TP> extends Object implements MutableAutomaton<Integer,I,T,SP,TP>, StateIDs<Integer>, UniversalFiniteAlphabetAutomaton<Integer,I,T,SP,TP>, SupportsGrowingAlphabet<I>, StateLocalInput<Integer,I>, Serializable
This class provides basic implementations (as far as possible on this abstract level) for several of the implemented concepts and offers utility methods to subclasses, for updating their array-based automata data.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractCompact.Payload
A utility class that encapsulates necessary information for performing an update of the stored automata data.
|
| Modifier and Type | Field and Description |
|---|---|
protected static int |
DEFAULT_INIT_CAPACITY |
protected static float |
DEFAULT_RESIZE_FACTOR |
protected static int |
INVALID_STATE |
| Constructor and Description |
|---|
AbstractCompact(Alphabet<I> alphabet,
AbstractCompact<?,?,?,?> other) |
AbstractCompact(Alphabet<I> alphabet,
int stateCapacity,
float resizeFactor) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAlphabetSymbol(I symbol) |
int |
addIntState(SP property) |
Integer |
addState(SP property) |
void |
clear() |
Alphabet<I> |
getInputAlphabet() |
Collection<I> |
getLocalInputs(Integer state) |
Integer |
getState(int id) |
int |
getStateId(Integer state) |
Collection<Integer> |
getStates() |
protected int |
getSymbolIndex(I input) |
int |
numInputs() |
abstract void |
setStateProperty(int state,
SP property) |
int |
size() |
StateIDs<Integer> |
stateIDs() |
protected static int |
toId(@Nullable Integer id) |
protected int |
toMemoryIndex(int stateId,
int inputId)
Returns for a given state id and input symbol index, the memory location for its associated data.
|
protected static @Nullable Integer |
toState(int id) |
protected void |
updateStateStorage(AbstractCompact.Payload payload)
Implementing classes should override this method in order to react to changes to the layout of their array-based
state data, e.g. due to calls to
MutableAutomaton.addState(). |
protected Object[] |
updateStateStorage(@Nullable Object[] oldStorage,
@Nullable Object defaultValue,
AbstractCompact.Payload payload)
Return a copy of the provided array with updated memory layout.
|
protected void |
updateTransitionStorage(AbstractCompact.Payload payload)
Implementing classes should override this method in order to react to changes to the layout of their array-based
transition data, e.g. due to calls to
MutableAutomaton.addState() or addAlphabetSymbol(Object). |
protected int[] |
updateTransitionStorage(int[] oldStorage,
int defaultValue,
AbstractCompact.Payload payload)
Return a copy of the provided array with updated memory layout.
|
protected @Nullable Object[] |
updateTransitionStorage(@Nullable Object[] oldStorage,
@Nullable Object defaultValue,
AbstractCompact.Payload payload)
Return a copy of the provided array with updated memory layout.
|
protected <S> S[] |
updateTransitionStorage(S[] oldStorage,
IntFunction<S[]> arrayConstructor,
S defaultValue,
AbstractCompact.Payload payload)
Return a copy of the provided array with updated memory layout.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddInitialState, addInitialState, addState, addTransition, addTransition, addTransitions, copyTransition, createTransition, removeAllTransitions, removeAllTransitions, removeTransition, setInitial, setStateProperty, setTransitionProperty, setTransitionstransitionGraphViewtransitionGraphViewgetStateProperty, getTransitionPropertygraphViewgetSuccessor, getSuccessors, getTransitions, powersetViewcreateDynamicStateMapping, createStaticStateMapping, iteratorgetInitialStates, getStates, getSuccessors, getSuccessorsforEach, spliteratorprotected static final float DEFAULT_RESIZE_FACTOR
protected static final int DEFAULT_INIT_CAPACITY
protected static final int INVALID_STATE
public AbstractCompact(Alphabet<I> alphabet, AbstractCompact<?,?,?,?> other)
public Collection<Integer> getStates()
getStates in interface SimpleAutomaton<Integer,I>public StateIDs<Integer> stateIDs()
stateIDs in interface SimpleAutomaton<Integer,I>public int size()
size in interface SimpleAutomaton<Integer,I>public int getStateId(Integer state)
getStateId in interface StateIDs<Integer>public int addIntState(SP property)
public Alphabet<I> getInputAlphabet()
getInputAlphabet in interface InputAlphabetHolder<I>public final void addAlphabetSymbol(I symbol)
addAlphabetSymbol in interface SupportsGrowingAlphabet<I>public Collection<I> getLocalInputs(Integer state)
getLocalInputs in interface StateLocalInput<Integer,I>public abstract void setStateProperty(int state,
SP property)
protected void updateStateStorage(AbstractCompact.Payload payload)
MutableAutomaton.addState().
Subclasses may use one of the updateStateStorage(Object[], Object, Payload)... methods to conveniently
delegate this task to this base class. This leaves subclasses only with the task to invoke the provided update
methods for each of their local array storages.
payload - the payload containing the necessary information for the update operation. This object must be passed
as-is to the updateStateStorage(Object[], Object, Payload)... methods.protected final Object[] updateStateStorage(@Nullable Object[] oldStorage, @Nullable Object defaultValue, AbstractCompact.Payload payload)
oldStorage - the current arraydefaultValue - default value for newly allocated array positionspayload - the payload objectprotected void updateTransitionStorage(AbstractCompact.Payload payload)
MutableAutomaton.addState() or addAlphabetSymbol(Object).
Subclasses may use one of the updateTransitionStorage(Object[], IntFunction, Object, Payload)... methods
to conveniently delegate this task to this base class. This leaves subclasses only with the task to invoke the
provided update methods for each of their local array storages.
payload - the payload containing the necessary information for the update operation. This object must be passed
as-is to the updateTransitionStorage(Object[], IntFunction, Object, Payload)... methods.protected final int[] updateTransitionStorage(int[] oldStorage,
int defaultValue,
AbstractCompact.Payload payload)
oldStorage - the current arraydefaultValue - default value for newly allocated array positionspayload - the payload objectupdateTransitionStorage(Object[], Object, Payload),
updateTransitionStorage(Object[], IntFunction, Object, Payload)protected final @Nullable Object[] updateTransitionStorage(@Nullable Object[] oldStorage, @Nullable Object defaultValue, AbstractCompact.Payload payload)
oldStorage - the current arraydefaultValue - default value for newly allocated array positionspayload - the payload objectupdateTransitionStorage(int[], int, Payload),
updateTransitionStorage(Object[], IntFunction, Object, Payload)protected final <S> S[] updateTransitionStorage(S[] oldStorage,
IntFunction<S[]> arrayConstructor,
S defaultValue,
AbstractCompact.Payload payload)
S - the storage typeoldStorage - the current arraydefaultValue - default value for newly allocated array positionspayload - the payload objectupdateTransitionStorage(int[], int, Payload),
updateTransitionStorage(Object[], Object, Payload)protected final int toMemoryIndex(int stateId,
int inputId)
stateId - the state idinputId - the index of input symbolgetSymbolIndex(Object)protected final int getSymbolIndex(I input)
public final int numInputs()
Copyright © 2020. All rights reserved.