Skip to content

Add RawTable#is_full #354

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

Merged
merged 2 commits into from
Sep 8, 2022
Merged

Add RawTable#is_full #354

merged 2 commits into from
Sep 8, 2022

Conversation

braddunbar
Copy link
Contributor

@braddunbar braddunbar commented Aug 21, 2022

There's currently no way to tell if a particular bucket is full. This can be handy for choosing a random element or iterating over a hash table in a specific order of buckets, so I've added the is_full function to RawTable.

@braddunbar braddunbar force-pushed the is-full branch 2 times, most recently from 45afad8 to ddf3ae9 Compare September 2, 2022 23:34
There's currently no way to tell  if a particular bucket is full. This
can be handy for choosing a random element or iterating over a hash
table in a specific order of buckets, so I've added the is_full function
to RawTable.
@braddunbar
Copy link
Contributor Author

Ok, so I changed this up so the build is passing and also refactored a bit. Hope you like it!

Also, I'm considering using is_bucket_full instead of is_full because is_empty seems like it's the opposite of is_full, but it most certainly is not. Maybe it's only confusing to me though! 🤷‍♀️

I would love any feedback on the name, the general idea, or anything else you'd like to talk about! 😺

@Amanieu
Copy link
Member

Amanieu commented Sep 3, 2022

I think is_bucket_full is a better name, is_full might be confused with asking whether the table is full to capacity.

Otherwise I think this is a good addition, but it should be unsafe since there is no bounds checking on the bucket index.

@braddunbar
Copy link
Contributor Author

Done and done. Thank you for the feedback @Amanieu!

braddunbar added a commit to braddunbar/hashbrown that referenced this pull request Sep 3, 2022
Just like rust-lang#335 did for `HashMap`, I'd like to add access to the
underlying `RawTable` for `HashSet`. I intend to use it in conjunction
with rust-lang#354 to pull random elements from a `HashSet`.
@braddunbar braddunbar mentioned this pull request Sep 3, 2022
braddunbar added a commit to braddunbar/hashbrown that referenced this pull request Sep 3, 2022
Just like rust-lang#335 did for `HashMap`, I'd like to add access to the
underlying `RawTable` for `HashSet`. I intend to use it in conjunction
with rust-lang#354 to pull random elements from a `HashSet`.
braddunbar added a commit to braddunbar/hashbrown that referenced this pull request Sep 3, 2022
Just like rust-lang#335 did for `HashMap`, I'd like to add access to the
underlying `RawTable` for `HashSet`. I intend to use it in conjunction
with rust-lang#354 to pull random elements from a `HashSet`.
@Amanieu
Copy link
Member

Amanieu commented Sep 8, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Sep 8, 2022

📌 Commit 1721ec5 has been approved by Amanieu

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Sep 8, 2022

⌛ Testing commit 1721ec5 with merge 2784682...

@bors
Copy link
Contributor

bors commented Sep 8, 2022

☀️ Test successful - checks-actions
Approved by: Amanieu
Pushing 2784682 to master...

@bors bors merged commit 2784682 into rust-lang:master Sep 8, 2022
@braddunbar braddunbar deleted the is-full branch September 8, 2022 12:40
bors added a commit that referenced this pull request Sep 8, 2022
Add HashSet#raw_table

Just like #335 did for `HashMap`, I'd like to add access to the underlying `RawTable` for `HashSet`. I intend to use it in conjunction with #354 to pull random elements from a `HashSet`.

Let me know if I've missed something here or you'd like things implemented differently. I'll be happy to change it up!
@braddunbar
Copy link
Contributor Author

Thank you!

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.

3 participants