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

Hash of std::vector<dna4> is linear, should be constant for unordered_maps. #1122

Closed
h-2 opened this issue Jun 24, 2019 · 2 comments
Closed
Milestone

Comments

@h-2
Copy link
Member

h-2 commented Jun 24, 2019

Interesting: https://en.cppreference.com/w/cpp/utility/hash says

The actual hash functions are implementation-dependent and are not required to fulfill any other quality criteria except those specified above. Notably, some implementations use trivial (identity) hash functions which map an integer to itself. In other words, these hash functions are designed to work with unordered associative containers, but not as cryptographic hashes, for example.

But, when using unorderd_map it says in https://en.cppreference.com/w/cpp/container/unordered_map/hash_function:

Complexity

Constant.

@marehr
Copy link
Member

marehr commented Jun 27, 2019

Just one remark the standard library uses https://github.com/gcc-mirror/gcc/blob/d1ca0650375baefa8851f7b1bebf70ebb1ea1446/libstdc%2B%2B-v3/libsupc%2B%2B/hash_bytes.cc#L74 for strings, which is linear, but uses some internal shenanigans to cache results of hash operations.

@smehringer
Copy link
Member

Since hashing for containers is also linear do we still want to implement a constant version (by sampling or else)?

@h-2 h-2 added this to the Backlog milestone Sep 30, 2019
@h-2 h-2 closed this as completed Sep 30, 2019
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

No branches or pull requests

3 participants