I'm doing something similar with sparsetable:
typedef sparsetable<string,48> index_t;
Works well when you know the range of unsigned integer keys. The
integer is effectively the hash.
> You received this message because you are subscribed to the Google Groups "google-sparsehash" group.
> To post to this group, send email to google-s...@googlegroups.com.
> To unsubscribe from this group, send email to google-sparseh...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-sparsehash?hl=en.
If you wanted to maintain uniqueness you could keep pointers in the
sparsetable instead and have an unordered_set to store the actual
values, or you could build a custom hash function for your
Depends a lot on what your use case is, as usual!
You can do something like
sparse_hash_map<int, whatever> foo;
foo = whatever;
foo = whatever;
But I agree a sparsetable is more natural for this app.
always enjoy a challenge! The ambiguous nature of the term vector is a
wonderful source of misunderstanding :)
To put a custom data structure in an unordered type map requires the
definition of both an equality and a hash function for that structure.
Equality functions are easy but hash functions are an endless source
of benchmarking fun. I've put a simple example here:
which uses the suggested hashing from here:
While it always fun to write your own code, there are some libraries
which cover this arena:
Hope that helps!
yes, the equality function will compare the two values with the same
hash and take the appropriate action. This action varies between
hashmap implementations and is another source of endless fun :)