United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6182958 : (coll) Add an entryList() method to LinkedHashMap

Details
Type:
Enhancement
Submit Date:
2004-10-21
Status:
Open
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
Component:
core-libs
OS:
windows_xp
Sub-Component:
java.util:collections
CPU:
x86
Priority:
P4
Resolution:
Unresolved
Affected Versions:
5.0
Targeted Versions:

Related Reports

Sub Tasks

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

                                    

Comments



Hardware and Software, Engineered to Work Together