2 Replies Latest reply on Mar 15, 2006 9:12 AM by tomasz bandura

    linkedhashmap and order of elements

    tomasz bandura Newbie


      i use jbosscache 1.2.4 with the FileCacheLoader

      My model includes LinkedHashMap (there are stored elements from a file)

      public class MyModel{

      private LinkedHashMap<String, other_object> elementMap;


      I store it in TreeCacheAop (

      For me the critical meaning has the order of the element - it has to be the same like ne the reading file.

      Unfortunately after the reading ( cache.getObject() ), elements are not in expected order.

      How can i solve this problem? I need to use a map structure because a lot of methods search by key.

      thnx in advance



        • 1. Re: linkedhashmap and order of elements
          Scott Marlow Master

          LinkedHashMap is currently not supported. I added LinkedHashMap to Jira issue http://jira.jboss.com/jira/browse/JBCACHE-166. You can vote for this Jira issue if you think its important.

          We currently support the following implementations:
          HashMap - This is the only only offering hashed key lookup but is not ordered.
          HashSet - The items are not ordered.
          ArrayList - The items are ordered but no hashed key lookup.

          The above are the current constraints as the other concrete collections classes aren't supported yet.

          I suppose that you could put your key value pairs in a HashMap for fast lookup. You could also put the values in an arraylist for ordered iteration (you could put the key in also if needed.) Or perhaps you only want to put the key values in the arraylist.

          • 2. Re: linkedhashmap and order of elements
            tomasz bandura Newbie

            thank you for the fast response,

            the solution with additiolnal arraylist is enough for me now

            90% operations concern fast lookup and the rest - listing all elements in right order

            have a nice day