c++ - unordered_map with forbidden collisions -
i want implement performance-optimized variant of unordered_map works in several phases:
- initialization: insert 100 elements
std::map - preparation: magic, converting
std::mapvariant ofstd::unordered_map - work: perform large (unbounded) number of lookups; insertions/deletions forbidden
in order make "work" phase fast possible, choose hashing function has no collisions given set of keys (gathered @ initialization phase).
i measure how performance improvement can trick. going experiment, possibly going production code.
does standard library have facilities implementation (e.g. finding how many collisions given unordered_map has; or changing hashing function)? or should make own implementation instead?
here "collision management" api:
size_type bucket_count() const; size_type max_bucket_count() const; size_type bucket_size(size_type n) const; size_type bucket(const key_type& k) const; local_iterator begin(size_type n); local_iterator end(size_type n); const_local_iterator begin(size_type n) const; const_local_iterator end(size_type n) const; const_local_iterator cbegin(size_type n) const; const_local_iterator cend(size_type n) const; in nutshell, bucket_size(n) gives number of collisions nth bucket. can buckets key, , can iterate on buckets local_iterator.
for changing hash function, assign/construct new container, old hash function new.
Comments
Post a Comment