Package org.xcsp.common.structures
Class Transitions
- java.lang.Object
-
- org.xcsp.common.structures.Transitions
-
public final class Transitions extends Object
An object encapsulating a list of transitions. This is sometimes useful when defining finite automatons.
-
-
Constructor Summary
Constructors Constructor Description Transitions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Transitions
add(String transitions)
Adds transitions to this object.Transitions
add(String firstState, int[] symbols, String secondState)
Adds some transitions to this object, one for each (integer) symbol.Transitions
add(String firstState, Object symbol, String secondState)
Adds a transition to this object.Transitions
add(String firstState, Range range, String secondState)
Adds some transitions to this object, one for each (integer) symbol contained in the specified range.Transitions
add(java.util.stream.Stream<Transition> transitions)
Adds transitions from a stream to this object.Transitions
add(Transition transition)
Adds a transition to this object.static Transitions
parse(String transitions)
Parses the specified string and returns an objectTransitions
that contains a list of transitions.Transition[]
toArray()
Returns an array with collected objectsTransition
String
toString()
-
-
-
Method Detail
-
parse
public static Transitions parse(String transitions)
Parses the specified string and returns an objectTransitions
that contains a list of transitions. The string must represent a sequence of transitions as defined in XCSP3. For example, it could be"(q0,0,q2)(q0,1,q3)(q1,0,q3)(q2,1,q3)"
when symbols are defined by integers or"(q0,a,q2)(q0,b,q3)(q1,a,q3)(q2,b,q3)"
when symbols are defined by strings.- Parameters:
transitions
- a string representing a sequence of transitions- Returns:
- an object
Transitions
containing a list of transitions after parsing the specified argument
-
add
public Transitions add(String transitions)
Adds transitions to this object.- Parameters:
transitions
- a string representing a sequence of transitions- Returns:
- this object (for chaining)
-
add
public Transitions add(Transition transition)
Adds a transition to this object.- Parameters:
transition
- a transition to be added- Returns:
- this object (for chaining)
-
add
public Transitions add(java.util.stream.Stream<Transition> transitions)
Adds transitions from a stream to this object.- Parameters:
transitions
- a stream of transitions- Returns:
- this object (for chaining)
-
add
public Transitions add(String firstState, Object symbol, String secondState)
Adds a transition to this object.- Parameters:
firstState
- the first state, where the transition beginssymbol
- the symbol labeling the transitionsecondState
- the second state, where the transition ends- Returns:
- this object (for chaining)
-
add
public Transitions add(String firstState, int[] symbols, String secondState)
Adds some transitions to this object, one for each (integer) symbol.- Parameters:
firstState
- the first state, where the transition beginssymbols
- the different symbols (here, integers) labeling the transitionsecondState
- the second state, where the transition ends- Returns:
- this object (for chaining)
-
add
public Transitions add(String firstState, Range range, String secondState)
Adds some transitions to this object, one for each (integer) symbol contained in the specified range.- Parameters:
firstState
- the first state, where the transition beginsrange
- the different symbols (here, integers contained in the range) labeling the transitionsecondState
- the second state, where the transition ends- Returns:
- this object (for chaining)
-
toArray
public Transition[] toArray()
Returns an array with collected objectsTransition
- Returns:
- an array with collected objects
Transition
-
-