The best I can suggest is to store a vector of items as the value of
your sparse_hash_map. I know it's not a perfect solution.
craig
That's tricky. What items are you putting in the sparsemap? Do they
have a bit to spare? If so, you could save space by making your
hash-value be a union of your object and a pointer, using that bit to
distinguish the two parts of the union (you'd want to make it the low
bit, and just mask it off to get the real pointer, which will always
have 0 in its bottom two bits).
For the common case of one object per key, you just put the object in;
if more objects, you have a pointer to an array of objects. Once
you're in the array, you can use your extra bit to indicate whether or
not the item is the last item in the array.
This is about as space-efficient as you can get, but is very ugly, and
probably pretty fragile.
What methods would you need to call on this multimap? I assume
equal_range()? If all you needed to do was iterate over the resulting
map, then it's easier to add to sparse_hash_map. But equal_range() is
hard, because there's no way to guarantee items with the same key will
be next to each other in the hashtable.
craig