Hi Craig,
Attached is a patch to implement deleted_key and empty_key. I've added a
very simple
unit test to make sure that all six cases at least compile. I haven't yet
added
documentation.
On Dec 9, 6:07 pm, Craig Silverstein <csilv...@google.com> wrote:
...
> I guess we'll have to figure out reasonable answers for these to give
> when the deleted key and empty key haven't been set yet.
I'm asserting that use_deleted or use_empty are true, which is a nice simple
solution. Another possibility is to return
pair<key_type, bool>(delkey, use_deleted)
Cheers,
Shaun
2009-12-31 Shaun Jackman <sjac...@gmail.com>
* google/sparsehash/densehashtable.h (empty_key, deleted_key): New
function.
* google/dense_hash_map: Ditto.
* google/dense_hash_set: Ditto.
* google/sparsehash/sparsehashtable.h (deleted_key): New function.
* google/sparse_hash_map: Ditto.
* google/sparse_hash_set: Ditto.
* hashtable_unittest.cc (test_int, TestOperatorEquals): Add unit tests.
Attachments:
get_deleted_key.diff 6.6 KB
Comment #3 on issue 47 by csilvers: Feature request: get deleted_key and
empty_key
http://code.google.com/p/google-sparsehash/issues/detail?id=47
Thanks for the patch! I applied it successfully and tested it, and all
looks good. I
made a few minor changes: mostly formatting, but also making the new
methods const in
the wrapper classes (they were already const in foohashtable.h, but not in
foo_hash_{map,set}).
I'll have one more pair of eyes look it over here, and assuming all goes
well, it will
be in the next release.
One more thing: can you provide a patch to the doc files, to document these
new
methods, in the appropriate places (if any)? I haven't looked yet to see
where they
might best fit.
Thanks for catching the const-ness. I missed that. Are you happy with the
assert(use_deleted)? I'll work on documentation next.
Cheers,
Shaun
Yes, I think the asserts are fine -- we get to decide the semantics of these
functions, which is always nice. :-) Just be sure to document that it's
illegal to
call foo_key before set_foo_key.
Comment #7 on issue 47 by csilvers: Feature request: get deleted_key and
empty_key
http://code.google.com/p/google-sparsehash/issues/detail?id=47
This should be resolved in sparsehash 1.6, just released.