HashMap does not remove a key
See original GitHub issueIt seems like the problems with TrieMap
implementation persist. I just observed a case where HashMap would not remove a key with both Remove
. I temporarily fixe dit with toHashMap(hashMap.AsEnumerable())
.
I’ll try to replicate it and update the issue.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
HashMap Remove is not working
However it seems that the hash code is changing. When I call the remove function, all hashes saved inside the hash map return...
Read more >Remove an Entry from a Java HashMap
We use this method in case we want to delete an entry only if a key is mapped to a specific value. In...
Read more >HashMap remove() Method in Java
The java.util.HashMap.remove() is an inbuilt method of HashMap class and is used to remove the mapping of any particular key from the map....
Read more >How to Remove Entry (key/value) from HashMap in Java ...
Some programmers will say No, you cannot remove elements from HashMap while iterating over it. This will fail fast and throw concurrent modification...
Read more >Java HashMap remove()
The syntax of the remove() method is: hashmap.remove(Object key, Object value);. Here, hashmap is an object of the HashMap class.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Everything seems to work fine. Thanks! Closing the issue.
Ok, I found the core issue. It’s fixed in
3.3.16
if you want to run it through your tests.Essentially as the trie grows the mask for each entry has a different value;
2085595311
has a mask of32768
at level 1, but when there’s multiple entries on level one with the same mask then a new level is created and the two items move to that level.2085595311
then has a mask of32
.When removing one of the items, so there’s only one left, there was a check for this so that level 2 gets removed and the one item that’s left moves back to level 1. What wasn’t happening was a recalculation of the mask from
32
back to32768
. Which meant subsequent checks to see if the item exists would fail and so2085595311
could be added again.Because of this I’ve been able to remove my other temporary fixes, because I suspect this is the only issue.
The joys of highly optimised imperative programming /sarcasm