Skip to content
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

implementation of Hash for BitSet #64

Open
EWurbel opened this issue Sep 26, 2023 · 4 comments
Open

implementation of Hash for BitSet #64

EWurbel opened this issue Sep 26, 2023 · 4 comments

Comments

@EWurbel
Copy link

EWurbel commented Sep 26, 2023

I have several projects which uses collections of BitSet objects intensely, and I need to store them in hashsets or hashmaps (or store structures containing BitSet objects in hashsets or hashmaps).
At this time this is not possible. I plan to clone the repo and implement it. If it is convincing I will probably make a pull request.

@zesterer
Copy link
Contributor

I'm such a feature would be appreciated.

@EWurbel
Copy link
Author

EWurbel commented Sep 27, 2023

Hi. I've done the implementation of the Hash interface (this is quite simple, it's a matter of calling the hash() method on the layer0 slice).
So the modification just adds 5 lines of code in lib.rs

Before issuing a pull request I have a question.

I coded a test program to test for the effectiveness of the default hashing algorithm (i.e. lack of collisions), both using raw hash values and restrictions over a certain number of bits. It works nicely, at last for my needs.

Could it be a good idea to incorporate this program in the crate, and if so, which status to use ? This is not really a test, not really a benchmark, perhaps an example ?

I wait for an advice on this before issuing a pull request.

@zesterer
Copy link
Contributor

I'm not sure how useful that would be, but if you wish. Consumers of hash function shouldn't assume a lack of collisions: a hash function that always returns 0 is still a valid hash function.

@EWurbel
Copy link
Author

EWurbel commented Sep 27, 2023

You are right, I should not have said "lack of collisions", but minimization of the number of collisions.
But you are right, this program was mainly for my own use. I'll prepare a pull request without it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants