-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
IntMap capacity limitations #6113
Comments
Looking into it now. |
There's no issue here; when you insert the same key into a Map, it replaces the original value with the new value, and returns the original value (see: IntMap.put() docs, or Map.put() in the JDK). And that's all that's happening; your test always inserts 3 keys (results of getIndex()) when that key already exists in the IntMap, and 11424 are inserted with no duplicate present. I added debug prints when an index is repeated:
That's 3 duplicates, and 3 less items in the IntMap as a result. If 11424 was a hard maximum, then the following would be impossible:
But we actually can get more than 11424 items in a thoroughly-tested Map implementation... One of the many tests this went through in January for a PR I made involved benchmarking the libGDX collections with 100,000 or 1,000,000 entries put into it, so I was pretty confident that it could handle 11,427. This test does expose a quirk of 1.9.10's hash-based collections, and it's another reason that PR for 1.9.11 matters -- ObjectMap, ObjectSet, IntMap, IntIntMap, IntFloatMap, LongMap, IdentityMap, OrderedMap, and OrderedSet (did I miss any?) will rarely call |
Thanks for investigating! I'll re-review how I'm calculating my indices in-game but there shouldn't be duplicates. Must have just been a coincidence that it was always 11425 entries on both the game and the unit test. I'll re-open the issue if I pinpoint anything in the IntMap. |
Issue details
Current IntMap implementation seems to have a maximum capacity around 11425 entries. I've tested on both 1.9.10 and 1.9.11-SNAPSHOT. I've also tried generating a hashcode() and equals() method for the TestObject.
See unit test below as reproduction.
Reproduction steps/code
The text was updated successfully, but these errors were encountered: