I hate to duplicate find() like that, but it is significantly faster to not have the intermediate pair ------------------------------------------------------------------
| 3055 | // significantly faster to not have the intermediate pair |
| 3056 | // ------------------------------------------------------------------ |
| 3057 | iterator find(const key_type& key) |
| 3058 | { |
| 3059 | size_type num_probes = 0; // how many times we've probed |
| 3060 | const size_type bucket_count_minus_one = bucket_count() - 1; |
| 3061 | size_type bucknum = hash(key) & bucket_count_minus_one; |
| 3062 | |
| 3063 | while (1) // probe until something happens |
| 3064 | { |
| 3065 | typename Table::GrpPos grp_pos(table, bucknum); |
| 3066 | |
| 3067 | if (!grp_pos.test_strict()) |
| 3068 | return end(); // bucket is empty |
| 3069 | if (grp_pos.test()) |
| 3070 | { |
| 3071 | reference ref(grp_pos.unsafe_get()); |
| 3072 | |
| 3073 | if (equals(key, get_key(ref))) |
| 3074 | return grp_pos.get_iter(ref); |
| 3075 | } |
| 3076 | ++num_probes; // we're doing another probe |
| 3077 | bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one; |
| 3078 | assert(num_probes < bucket_count() |
| 3079 | && "Hashtable is full: an error in key_equal<> or hash<>"); |
| 3080 | } |
| 3081 | } |
| 3082 | |
| 3083 | // Wish I could avoid the duplicate find() const and non-const. |
| 3084 | // ------------------------------------------------------------ |
no test coverage detected