question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HashMap does not remove a key

See original GitHub issue

It 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:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
iamimcommented, Aug 19, 2019

Everything seems to work fine. Thanks! Closing the issue.

1reaction
louthycommented, Aug 19, 2019

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 of 32768 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 of 32.

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 to 32768. Which meant subsequent checks to see if the item exists would fail and so 2085595311 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found