getConflictingAltSubsets static method
This function gets the conflicting alt subsets from a configuration set.
For each configuration c
in configs
:
map[c] U= c.{@link ATNConfig#alt alt} # map hash/equals uses s and x, not alt and not pred
Implementation
static List<BitSet> getConflictingAltSubsets(ATNConfigSet configs) {
final configToAlts =
HashMap<ATNConfig, BitSet>(equals: (ATNConfig? a, ATNConfig? b) {
if (identical(a, b)) return true;
if (a == null || b == null) return false;
return a.state.stateNumber == b.state.stateNumber &&
a.context == b.context;
}, hashCode: (ATNConfig o) {
/**
* The hash code is only a function of the {@link ATNState#stateNumber}
* and {@link ATNConfig#context}.
*/
var hashCode = MurmurHash.initialize(7);
hashCode = MurmurHash.update(hashCode, o.state.stateNumber);
hashCode = MurmurHash.update(hashCode, o.context);
hashCode = MurmurHash.finish(hashCode, 2);
return hashCode;
});
for (var c in configs) {
var alts = configToAlts[c];
if (alts == null) {
alts = BitSet();
configToAlts[c] = alts;
}
alts.set(c.alt);
}
return configToAlts.values.toList();
}