LinkedHashMap

Issue #12 new
Rob Eden created an issue

Originally reported by Ralf Wiebicke

I'd like to have an equivalent of LinkedHashMap. This is a HashMap, that maintains an order of its contents. This can be used to build a LRU-Map.

Original SF issue

Comments (7)

  1. Rob Eden reporter

    From an original SF issue, Robin Thomas supplies this:

    For a project, I wanted to use THashMap, but I needed to preserve insertion order of the entries when iterating. With the addition of an int[] field to THashMap and several method overrides, insertion order is preserved a la LinkedHashMap.

    The attachment is a .zip with two files: THashMapOrderedByInsert.java, and a test class copy-wasted from THashMapTest.java in 2.0.4 src distribution.

  2. Ralph Su

    Is there a planning to adopt this one in release? I'm trying to adopt trove4j for an existing project, while there is a requirement of iterating linkedhashmap through insertion order..

  3. Rob Eden reporter

    @ralphsu You could use the one attached to this bug and let us know your experiences. It hasn't gone through extensive testing yet (which is why it isn't in the main code base yet).

  4. Ralph Su

    I did try the attached one. With the latest code, it seems some of the class not found in the main code base like TObjectHashStrategy which is referenced in one of the constructor. By eliminate the not found class, the attachment works find to me. Insertion order was preserved, but i had to say that i haven't do more testing like performance or memory usage testing. It now passed through all my test cases including those rely on the insertion order.

  5. Gururaj Desai

    I also have the same requirement. Tried the attached one but I am getting compilation issues with 3.1a1. How to resolve it?

  6. Rob Eden reporter

    This isn't supported at the moment, so it's not something I can help with. Looks like @ralphsu got it working so maybe he could help.

    If can't really be accepted into the main distribution until it's had some performance review. At some point I'm planning to have an "experimental" module which it could be pulled into.

  7. Log in to comment