Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6266354
Votes 2
Synopsis (coll) LinkedHashMap to support ListIterators
Category java:classes_util
Reported Against
Release Fixed
State 5-Cause Known, request for enhancement
Priority: 4-Low
Related Bugs
Submit Date 06-MAY-2005
Description
A DESCRIPTION OF THE REQUEST :
Since LHM is ordered you can use LHM.iterator() LHM.values() and LHM.entries() to get items in order.  However, you cannot get values in *reverse* order as there is no equivalent of Vector.listIterator(int).

JUSTIFICATION :
Performance and  usability.

This is what i expected it to do already !

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
LHM.values() and LHM.entries() to return an AbstractSequentialList rather than a Collection interface (implemented as an anonymous extension of AbstractCollection).  **This would not break any existing applications**
ACTUAL -
LHM.values() and LHM.entries() return an AbstractCollection that cannot therefore present a ListIterator to the user.

CUSTOMER SUBMITTED WORKAROUND :
Currently you have to use :

Collections.list( Collections.enumeration( linkedhashmap.values() ) );

The performance of this is appalling considering the underlying collection is a linked list.  Obviously, we maintain a second index to get around this.
  xxxxx@xxxxx   2005-05-06 06:41:27 GMT
Work Around
N/A
Evaluation
We should seriously consider the same kinds of bidirectional capabilities for
LinkedHashMap as are currently being added to LinkedList, etc.
Posted Date : 2005-08-08 00:25:26.0
Comments
  
  Include a link with my name & email   

Submitted On 16-OCT-2007
kevinb9n
Part one of the proposal is to modify LinkedHashMap.values() (both signature and implementation) to return a List.  I can't comment on the utility of this change, but I can think of nothing fundamentally wrong with the idea.

Part two is to modify the "entries()" method; though this method doesn't exist, only entrySet(), which clearly can't return a Set.  But we can interpret this as a proposal to create a new method, which I would call entryList(), returning the same data as entrySet() only as a List.

Again, I don't see why not.  All the issues I've thought of have only to do with add() operations which these collection views don't support anyway.

Note that either of these changes would have the effect of promoting LinkedHashMap to become a bona fide _type_ in the API, no longer a mere implementation class.  Again... I don't see anything wrong with that.


Submitted On 19-MAR-2009
mlavine
This bug is related: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4848853.



PLEASE NOTE: JDK6 is formerly known as Project Mustang