Skip to content

Commit 05329bf

Browse files
committed
fix nfa.is_complete
for each state, this now collects the *set* of outgoing actions and then checks if every alphabet letter is contained.
1 parent 99173c3 commit 05329bf

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/nfa.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,13 @@ impl Nfa {
5050
letters.sort();
5151
// for each state, check if it has a transition for each letter in the alphabet
5252
for state in 0..self.nb_states() {
53-
let mut state_actions = self
53+
let state_actions = self
5454
.transitions
5555
.iter()
5656
.filter(|t| t.from == state)
5757
.map(|t| t.label.clone())
58-
.collect::<Vec<_>>();
59-
state_actions.sort();
60-
if state_actions != letters {
58+
.collect::<std::collections::BTreeSet<_>>();
59+
if !letters.iter().all(|l| state_actions.contains(*l)) {
6160
return false;
6261
}
6362
}

0 commit comments

Comments
 (0)