Skip to content

Add is_clear method - #79

Merged
jrraymond merged 1 commit into
petgraph:masterfrom
nicopap:is_clear
Jul 3, 2022
Merged

Add is_clear method#79
jrraymond merged 1 commit into
petgraph:masterfrom
nicopap:is_clear

Conversation

@nicopap

Copy link
Copy Markdown
Contributor

When using this library, the intent of checking if all elements in a bitset are disabled is better expressed with a specialized method. I doubt it's particularly more performant than bitset.count_ones(..) == 0, but when reading code using FixedBitSet, it's easier to understand what is going on with a bitset.is_clear() than a bitset.count_ones(..) == 0.

I also added docs so that it's less easy to get confused as to what "empty" means (I think the confusion was raised multiple times in the past)

@jrraymond

Copy link
Copy Markdown
Collaborator

Thanks. Can you please add some tests for this function?

Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs Outdated
@nicopap

nicopap commented Jul 3, 2022

Copy link
Copy Markdown
ContributorAuthor

Thank for the review! Very important to keep thing names consistent in documentation. I indeed picked up "element" by just looking at the iterator methods. I'll fix that.

A question: the docs use both "enabled/disabled" and "set/unset" for value = 1/0. You seem to prefer "set/unset", and I'll follow this preference, but I prefer "enabled/disabled" since "set" can also mean a set of values.

@nicopap

Copy link
Copy Markdown
ContributorAuthor

I'm very happy with the second pass on the docs. Although, in insight, I'm a bit skittish about both updating the doc on is_empty and len and adding is_clear.

@nicopap
nicopap requested a review from jrraymondJuly 3, 2022 10:47
@jrraymond

Copy link
Copy Markdown
Collaborator

"enabled/disabled" is ok. Using "bit" instead of element is more important.

Don't worry about updating the doc on is_empty and len.

Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs Outdated

@jrraymondjrraymond left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! As a final step, could you please add some test for is_clear()?

@jrraymond
jrraymond merged commit f9c9c09 into petgraph:masterJul 3, 2022
@nicopap

Copy link
Copy Markdown
ContributorAuthor

Thank you for the directions and the merge! Was the doc example code enough test?

Sign up for freeto 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

@nicopap@jrraymond