-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get word from complement lazy determinization #420
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
77d4352
fix: Make Nfa::get_words() a const method
Adda0 5c026ef
feat: Lazily get an arbitrary word from a complement of an NFA
Adda0 fbe9f18
feat: Add callback to determinize() to handle discovery of new macros…
Adda0 d670d51
fix: Reset synchronized iterator after each iteration
Adda0 f8767f2
feat: Allow passing alphabet missing some symbols in the transition r…
Adda0 b1dd803
perf: Minimize number of copies of state sets
Adda0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened here? Is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even after looking at it previously, I still cannot explain how it managed to work without the reset. One should intuitively clear the iterator for every macrostate.
clear()
is a fast O(1) operation, so I added it as this is what I would do if I implemented the function again. I can take a look once more and probably try to debug it to make sure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, I have done some more digging and I got it now. It works thanks to a lucky coincidence. Since we have been up until now always using the
SynchronizedIterator
(called advancer further for clarity) only to fully iterate over the whole vectors iterated over, the advancer remains clear after the while loopswhile(iterator.advance())
. That holds only because at the end of everyadvance()
, the iterators kept in the advancer are popped from the advancer when they iterated all the way to their respective end iterators. If we were to stop the iteration earlier for any macrostate, the iterators would remain in the advancer and the next macrostate would only add new iterators to these iterators from the previous macrostate. The advancer would iterate over all of them (the remaining ones and the new one which one actually want to iterate over) together, causing theadvance()
to not work correctly.As a rule of thumb, we should therefore always clear our advancers to make sure that this happenstance cannot occur. Henceforth, I consider this change to add
clear()
everywhere a valid one.