Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert deleted key into hashmap will cause size() be increased #92

Open
GoogleCodeExporter opened this issue Aug 14, 2015 · 2 comments
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Initiate a HashMap  (such as google::sparse_hash_map<int, int> hashmap;)
2. Set the deleted key  (hashmap.set_deleted_key(-1);)
3. Insert a delete key into it (hashmap.insert(std::make_pair(-1, -1 * 100));)
4. Check its size by call size() method, the size() is increased; but it is 
unable to be get via iterator.  

What is the expected output? What do you see instead?
If insert a deleted key, the size() should not be increased.

What version of the product are you using? On what operating system?
1.11 on Centos

Please provide any additional information below.


Original issue reported on code.google.com by Lingtao....@gmail.com on 7 May 2013 at 9:24

@PhilipDeegan
Copy link
Member

This is still the case.

@PhilipDeegan
Copy link
Member

This is only achievable by compiling with NDEBUG, otherwise an assertion error is given.

calling "erase.(map.deleted_key())" seems to do the trick. Maybe it should be somewhere in the code to do it on insert / operator[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants