public final class PrioritySensitiveNFATransitionSet extends NFATransitionSet
NFATransitionSet that is sensitive to insertion order, so sets with the
same elements are no longer considered equal if their element insertion order differs. The
insertion order reflects the priority of every transition, where elements added earlier are of
higher priority. This set will also stop accepting new elements as soon as a transition to a
final state was added (more specific: a transition that leads to a state that has another
transition to a final state, as denoted by
NFAState.hasTransitionToAnchoredFinalState(boolean) and
NFAState.hasTransitionToUnAnchoredFinalState(boolean). The transition to the final state
in the NFA does not consume a character, so it is treated as part of the transition leading to
its source state in the DFA generator. Example: NFA state 1 leads to NFA state 2, which leads to
final NFA state 3. The DFA generator will treat the transition from state 1 to state 2 as
"transition to final state" and incorporate the transition from state 2 to state 3 in it.). This
is necessary for correct DFA generation, since after reaching a final state, the DFA shall drop
all NFA states whose priority is lower than that of the final state. Since in this set insertion
order reflects priority, we do just that implicitly by dropping all add operations after a
transition to a final state was added.DFAGenerator,
DFAStateTransitionBuilder| Modifier and Type | Method and Description |
|---|---|
void |
add(NFAStateTransition transition)
Analogous to
NFATransitionSet.add(NFAStateTransition), but the new element will also
be refused if the transition set already contains a transition to a final state (see JavaDoc
of this class), i.e. |
void |
addAll(TransitionSet other)
Add all transitions contained in the given transition set.
|
static PrioritySensitiveNFATransitionSet |
create(NFA nfa,
boolean forward,
NFAStateTransition transition) |
PrioritySensitiveNFATransitionSet |
createMerged(TransitionSet other)
Create a merged set of
this and other by copying this and adding the
contents of other to the copy. |
boolean |
equals(Object obj)
Checks if the set is equal to another given set.
|
int |
hashCode()
Returns the hash code value for this set.
|
getTargetStateSet, isEmpty, isForward, iterator, leadsToFinalState, size, stream, toJson, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic static PrioritySensitiveNFATransitionSet create(NFA nfa, boolean forward, NFAStateTransition transition)
public PrioritySensitiveNFATransitionSet createMerged(TransitionSet other)
TransitionSetthis and other by copying this and adding the
contents of other to the copy.createMerged in interface TransitionSetcreateMerged in class NFATransitionSetother - the TransitionSet to be merged with the copy. Implementing classes may
accept objects of their own type only.this!public void add(NFAStateTransition transition)
NFATransitionSet.add(NFAStateTransition), but the new element will also
be refused if the transition set already contains a transition to a final state (see JavaDoc
of this class), i.e. NFATransitionSet.leadsToFinalState() is true.add in class NFATransitionSetpublic void addAll(TransitionSet other)
PrioritySensitiveNFATransitionSet.add(NFAStateTransition).addAll in interface TransitionSetaddAll in class NFATransitionSetother - the TransitionSet to be merged with this. Implementing classes
may accept objects of their own type only.PrioritySensitiveNFATransitionSet.add(NFAStateTransition)public int hashCode()
NFAStateTransition.getTarget(boolean) of all NFAStateTransitions in this set
in insertion order.hashCode in interface TransitionSethashCode in class NFATransitionSetpublic boolean equals(Object obj)
PrioritySensitiveNFATransitionSets and have the same target states in the
same order - This means that if both sets are iterated in insertion order,
their transitions must yield the same sequence of target states (as returned by
NFAStateTransition.getTarget(boolean)).equals in interface TransitionSetequals in class NFATransitionSet