Feature request: get_deleted_key

0 views
Skip to first unread message

ShaunJ

unread,
Dec 9, 2009, 3:14:32 PM12/9/09
to google-sparsehash
Pretty self explanatory. I want to detect when the deleted_key is
going to be inserted and change the deleted_key when this happens.
Right now I'm caching the deleted_key, but it would be easier to ask
the sparsehash itself.

Thanks,
Shaun

Craig Silverstein

unread,
Dec 9, 2009, 7:38:54 PM12/9/09
to google-s...@googlegroups.com
Seems reasonable to me. Just like we expose max_load_factor(). Can
you file a feature request at
http://code.google.com/p/google-sparsehash/issues/list
so we can keep track of it?

craig

Craig Silverstein

unread,
Dec 9, 2009, 9:07:22 PM12/9/09
to google-s...@googlegroups.com
} Pretty self explanatory. I want to detect when the deleted_key is
} going to be inserted and change the deleted_key when this happens.
} Right now I'm caching the deleted_key, but it would be easier to ask
} the sparsehash itself.

Actually, would you like to try your hand at a patch? I think the
right thing to do is to add functions called
key_type deleted_key() const
key_type empty_key() const

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.

You should also implement
key_type empty_key() const
for densehashtable.h.

Finally, you'll have to expose these methods up through
{dense,sparse}_hash_{map,set}, update the documentation for those four
files (in the doc/ directory), and add unittest cases that test the
behavior for all 6 variants (sparse/dense table/map/set) -- though
it's probably only one or two added tests, since we get a lot of test
coverage via the templatized test functions.

Quite a bit of machinery, but STL is like that. :-(

craig

ShaunJ

unread,
Dec 11, 2009, 1:07:02 PM12/11/09
to google-sparsehash
On Dec 9, 6:07 pm, Craig Silverstein <csilv...@google.com> wrote:
> } Pretty self explanatory. I want to detect when the deleted_key is
> } going to be inserted and change the deleted_key when this happens.
> } Right now I'm caching the deleted_key, but it would be easier to ask
> } the sparsehash itself.
>
> Actually, would you like to try your hand at a patch?  I think the
> right thing to do is to add functions called
>    key_type deleted_key() const
>    key_type empty_key() const

Sure, I'll give it a go.

Cheers,
Shaun
Reply all
Reply to author
Forward
0 new messages