I
- input symbol typeT
- transition typeSP
- state property typeTP
- transition property type@ParametersAreNonnullByDefault public 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)
Notifies the data structure that a new symbol should be added to the alphabet.
|
int |
addIntState(SP property) |
Integer |
addState(SP property)
Adds a state to the automaton.
|
void |
clear()
Removes all states and transitions.
|
Alphabet<I> |
getInputAlphabet() |
Collection<I> |
getLocalInputs(Integer state)
Returns the collection of input symbols for which a successor state is defined.
|
Integer |
getState(int id) |
int |
getStateId(Integer state) |
Collection<Integer> |
getStates()
Retrieves all states of the transition system.
|
protected int |
getSymbolIndex(I input) |
int |
numInputs() |
abstract void |
setStateProperty(int state,
SP property) |
int |
size()
Retrieves the size (number of states) of this transition system.
|
StateIDs<Integer> |
stateIDs() |
protected static int |
toId(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 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(Object[] oldStorage,
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 Object[] |
updateTransitionStorage(Object[] oldStorage,
Object defaultValue,
AbstractCompact.Payload payload)
Return a copy of the provided array with updated memory layout.
|
protected <T> T[] |
updateTransitionStorage(T[] oldStorage,
IntFunction<T[]> arrayConstructor,
T 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, wait
addInitialState, addInitialState, addState, addTransition, addTransition, addTransitions, copyTransition, createTransition, removeAllTransitions, removeAllTransitions, removeTransition, setInitial, setStateProperty, setTransitionProperty, setTransitions
transitionGraphView
transitionGraphView
getStateProperty, getTransitionProperty
graphView
getSuccessor, getSuccessors, getTransitions, powersetView
createStaticStateMapping, iterator
createDynamicStateMapping, getInitialStates, getStates, getSuccessors, getSuccessors
forEach, spliterator
protected 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()
SimpleAutomaton
getStates
in interface SimpleAutomaton<Integer,I>
public StateIDs<Integer> stateIDs()
stateIDs
in interface SimpleAutomaton<Integer,I>
public int size()
SimpleAutomaton
size
in interface SimpleAutomaton<Integer,I>
public int getStateId(Integer state)
getStateId
in interface StateIDs<Integer>
public void clear()
MutableAutomaton
public final Integer addState(@Nullable SP property)
MutableAutomaton
public Alphabet<I> getInputAlphabet()
getInputAlphabet
in interface InputAlphabetHolder<I>
public final void addAlphabetSymbol(I symbol) throws GrowingAlphabetNotSupportedException
SupportsGrowingAlphabet
GrowingAlphabet
) to handle
potentially shared state across multiple instances. If the needed requirements are not met, a GrowingAlphabetNotSupportedException
can be thrown.addAlphabetSymbol
in interface SupportsGrowingAlphabet<I>
symbol
- the symbol to add to the alphabet.GrowingAlphabetNotSupportedException
- if the data structure was not properly initialized (e.g. with a GrowingAlphabet
).public Collection<I> getLocalInputs(Integer state)
StateLocalInput
getLocalInputs
in interface StateLocalInput<Integer,I>
state
- the state for which the defined inputs should be returnedprotected 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(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 Object[] updateTransitionStorage(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 <T> T[] updateTransitionStorage(T[] oldStorage, IntFunction<T[]> arrayConstructor, @Nullable T defaultValue, AbstractCompact.Payload payload)
oldStorage
- the current arraydefaultValue
- default value for newly allocated array positionspayload
- the payload objectupdateTransitionStorage(int[], int, Payload)
,
updateTransitionStorage(Object[], Object, Payload)
protected static Integer toState(int id)
protected final int toMemoryIndex(int stateId, int inputId)
stateId
- the state idinputId
- the index of input symbolgetSymbolIndex(Object)
public final int numInputs()
Copyright © 2019. All rights reserved.