Closed GoogleCodeExporter closed 9 years ago
I don't see a bug here. In your example, you say the empty value will be put in
table[11] when you erase value2. But that shouldn't be the case. It should use
the deleted key. If the deleted key and empty key are the same then you'll have
problems; people using the library should take care to avoid that.
I'm marking this as CannotReproduce. Please correct me if that's incorrect.
Original comment by gp...@google.com
on 9 May 2012 at 7:09
You should check below my comment first.
* if the three values have same bucknum and user call "erase(value2)"
then table[11] will be set as empty value.
table[10] : value1
table[11] : empty
table[12] : value3*
dense_hash_table uses below to make buckum.
*size_type bucknum = hash(key) & bucket_count_minus_one;*
and if bucknum is same then
1. compare empty key
2. compare delete key
3. compare value key.
So, value #11 was deleted then value #12 will be not found.
Additionally, I found some comment in source but I think it's not enough.
// 2) resize(0):
// When an item is deleted, its memory isn't freed right
// away. This allows you to iterate over a hashtable,
// and call erase(), without invalidating the iterator.
// To force the memory to be freed, call resize(0).
// For tr1 compatibility, this can also be called as rehash(0).
--
/*********************************************
* @Name Bae, Dong Jin
* @Email Dongjin.Bae@access-company.com
* @Company Access Seoul Co., Ltd.
* @WebPage http://www.access-company.com
* @Comment Fools ignore complexity.
* Pragmatists suffer it. Some can avoid it.
* Geniuses remove it.
***********************************************/
Original comment by emd...@gmail.com
on 10 May 2012 at 12:38
Original issue reported on code.google.com by
emd...@gmail.com
on 9 May 2012 at 1:36