Opened 14 years ago
Last modified 3 years ago
#2841 new Feature Requests
boost::hash to support boost::dynamic_bitset
Reported by: | Owned by: | James E. King, III | |
---|---|---|---|
Milestone: | Component: | dynamic_bitset | |
Version: | Boost 1.43.0 | Severity: | Not Applicable |
Keywords: | Cc: | daniel_james@… |
Description
IIUC, there's no out-of-box support for hashing of dynamic_bitset.
Could something as simple as
template <typename B, typename A> friend std::size_t hash_value(const dynamic_bitset<B, A>& v) { return hash_value( v.m_bits ); }
be added to boost::dynamic_bitset
class?
Change History (13)
follow-up: 2 comment:1 by , 14 years ago
Cc: | added |
---|---|
Component: | hash → dynamic_bitset |
Owner: | changed from | to
comment:2 by , 14 years ago
Replying to danieljames:
I don't know anything about dynamic_bitset, but I suspect the hash function will also need to include the length of the bitset so that '1', '10' and '01' all have different hash values.
Well, yes, adding length may improve hashing quality. On the other hand, the length of m_bits
array directly correlates with the length of bitset, so it's (kind of) already included.
follow-up: 4 comment:3 by , 14 years ago
'0', '00', '000' and '0000' should have different hash values, but unless I've misunderstood dynamic_bitset m_bits will be the same for all of them.
comment:4 by , 14 years ago
Replying to danieljames:
'0', '00', '000' and '0000' should have different hash values, but unless I've misunderstood dynamic_bitset m_bits will be the same for all of them.
I think so too. It should be true for all zero bitsets with lengths <= bits per bitset block. For bigger lengths - two and more values would be hash_combined, resulting in different hash key.
Anyway, not including bitset length into hashing directly would have so small performance improvement, that I withdraw my previous comment. :)
comment:5 by , 13 years ago
"Cogito ergo I'm right and you're wrong."
-- Blair Houghton
viagra prezzo online purchase fioricet buy order cialis online BgnAuHX tramadol buy cheap
comment:6 by , 9 years ago
It would also be great if dynamic_bitset
supported std::hash
, which exists beginning with C++11.
comment:7 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Proposed fix in: https://github.com/boostorg/dynamic_bitset/pull/1
comment:8 by , 9 years ago
Milestone: | Boost 1.39.0 → Boost 1.56.0 |
---|
comment:10 by , 8 years ago
Milestone: | Boost 1.56.0 → Boost 1.58.0 |
---|---|
Version: | Boost 1.38.0 → Boost 1.43.0 |
Hello. And Bye.
comment:12 by , 3 years ago
Milestone: | Boost 1.58.0 |
---|---|
Owner: | changed from | to
Severity: | Optimization → Not Applicable |
Status: | assigned → new |
I don't know anything about dynamic_bitset, but I suspect the hash function will also need to include the length of the bitset so that '1', '10' and '01' all have different hash values.
Anyway, this needs to be implemented as part of dynamic_bitset so I'm passing it to it's maintainer. But I'm adding myself as a CC, so he can ask for assistance if needed.