JDK-6266354 : (coll) LinkedHashMap to support ListIterators
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-05-06
  • Updated: 2023-10-23
  • Resolved: 2023-10-23
Related Reports
Duplicate :  
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.
###@###.### 2005-05-06 06:41:27 GMT

Comments
What's being requested here is the ability to iterate a LinkedHashMap in reverse order. This is covered by Sequenced Collections, JEP 431, JDK-8280836. Closing as duplicate.
23-10-2023

EVALUATION We should seriously consider the same kinds of bidirectional capabilities for LinkedHashMap as are currently being added to LinkedList, etc.
08-08-2005