Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6182958

(coll) Add an entryList() method to LinkedHashMap

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      A DESCRIPTION OF THE REQUEST :
      Linked hashmap is described in the documentation as "Hash table and linked list implementation of the Map interface" but there is no way to view a linked hashmap as a list of entries.

      JUSTIFICATION :
      The linked hashmap implementation use linked list, but there is no easy way to view it as a list. So if you use a third party code that need list, the simple
      way to do this actually is to use a temporary list.

      In swing application, the use temporary list breaks the design pattern MVC and transform the simple fact to view (on screen) a linked hash map into a JList
      in a nightmare.

      Another justification, there is no way to iterate on entries in backward order even if the current implementation permit this.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Add a method entryList() in the LinkedHashMap class.

      proposed signature :
      public List<Map.Entry<K,V>> entryList();
      the returned List may implements SequentialList.

        To be symetric, a method entryList() could be added to LinkedHashSet
      public List<E> asList();
      ACTUAL -
      view as an entry list :

      LinkedHashMap<String,String> map=new LinkedHashMap<String,String>();
      LinkedList<Map.Entry<String,String>> list=
        new LinkedList<Map.Entry<String,String>>();
      list.addAll(map.entrySet());
      ###@###.### 10/21/04 23:29 GMT

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: