Miscellaneous Container Templates

What is the equivalent to boost::unordered_map::bucket_size(int) ?

Asked by Lailoken on 2010-04-08

I've been using the boost bucket_size() method for my own internal statistics... any way you have something similar you can expose?

I'm aware of collect_statistics, but wanted to use my own regardless.

Question information

Language:
English Edit question
Status:
Answered
For:
MCT Edit question
Assignee:
No assignee Edit question
Last query:
2010-04-08
Last reply:
2010-04-09
Lailoken (lailoken-gmail) said : #1

(I print out a debug distribution of used buckets to get an idea of the
quality of my hash function)

Paul Pogonyshev (doublep) said : #2

There is no direct equivalent because this function makes no sense for closed hashing. In closed hashing each bucket is either empty or contains exactly 1 element, never more.

However, information returned by collect_statistics() in fields 'avg_present_lookup' and 'max_present_lookup' gives about the same information. With unordered_*::bucket_size() you get limit on the number of comparisons used if a value ends up in that bucket (i.e. it is 1, 2, ... N comparisons depending on whether it is first or last). '*_present_lookup' fields have very similar meaning, except they are for all elements in the table at once.

In practice, if 'avg_present_lookup' is not considerably higher than 1 (maybe 1.5 is the limit for good values, not sure), then your hash function is good. Also note that the value may depend on the number of debris in the table; refer to documentation's 'Performance Tips' if use erase().

Can you help with this problem?

Provide an answer of your own, or ask Lailoken for more information if necessary.

To post a message you must log in.