Skip to content

Zeros iterator#32

Closed
mneumann wants to merge 3 commits intopetgraph:masterfrom
mneumann:zeros_iterator
Closed

Zeros iterator#32
mneumann wants to merge 3 commits intopetgraph:masterfrom
mneumann:zeros_iterator

Conversation

@mneumann
Copy link
Contributor

No description provided.

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
@james7132 james7132 mentioned this pull request Jan 16, 2023
@james7132
Copy link
Collaborator

Closing in favor of #89.

@james7132 james7132 closed this Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants