Zeros iterator#32
Closed
mneumann wants to merge 3 commits intopetgraph:masterfrom
mneumann:zeros_iterator
Closed
Conversation
In [munkres-rs][1] I have to iterate over all uncovered rows and columns of a matrix. If "1" means covered, this means that I have to iterate over all zero bits of a FixedBitSet. I solved this by initially setting all bits to "1": all_rows_uncovered.set_range(.., true); and then setting a row or column to "0" when it is covered. This "inverse" logic is unintuitive. IMHO, it is better to talk about the positive case when a row/column is covered instead of the negative case when a row/column is uncovered. Negative logic sucks! The zeros() iterator uses almost the same logic as the ones() iterator, except that it negates the current block. For instance if the current block is 0b1010, the zero bits are 0 and 2. We negate it to 0b0101 and look for the "1" bits, i.e. 0 and 2. This works fine, except for the last block, which might contain "unused" bits (when "bits % BITS > 0"). In this case we need to apply a mask to the last (negated) block. [1]: https://github.com/mneumann/munkres-rs
Merged
Collaborator
|
Closing in favor of #89. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.