Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

std, boost or other widespread implementation of a hash table container with implicit keys

If I understand it correctly, both std::map and std::unordered_map store keys explicitely (store pairs of keys / values). Is there some other ready to use container (std, boost or other widespread implementation) which would not store the key, but rather allow deriving the key from the stored value using a function (i.e. to use implicit key?).

like image 755
Suma Avatar asked Jan 19 '12 12:01

Suma


1 Answers

std::set or std::unordered_set, with suitable hash and/or comparison functions for the stored value type.

However, lookup will be done by the stored value type, not the key, so you'll also need a way to fabricate a temporary object from a key.

like image 157
Mike Seymour Avatar answered Oct 02 '22 23:10

Mike Seymour