operator == method

  1. @override
bool operator ==(
  1. Object other
)
override

Two DFAState instances are equal if their ATN configuration sets are the same. This method is used to see if a state already exists.

Because the number of alternatives and number of ATN configurations are finite, there is a finite number of DFA states that can be processed. This is necessary to show that the algorithm terminates.

Cannot test the DFA state numbers here because in {@link ParserATNSimulator#addDFAState} we need to know if any other state exists that has this exact set of ATN configurations. The {@link #stateNumber} is irrelevant.

Implementation

@override
bool operator ==(Object other) {
  // compare set of ATN configurations in this set with other
  if (identical(this, other)) return true;

  if (other is! DFAState) {
    return false;
  }

  return configs == other.configs;
}