United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4848853 : (coll) Modify LinkedHashMap and LinkedHashSet to include first() and last()

Details
Type:
Enhancement
Submit Date:
2003-04-15
Status:
Open
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
Component:
core-libs
OS:
linux,windows_2000
Sub-Component:
java.util:collections
CPU:
x86
Priority:
P4
Resolution:
Unresolved
Affected Versions:
1.4.1
Targeted Versions:

Related Reports

Sub Tasks

Description
eldes 

Name: rmT116609			Date: 04/15/2003


A DESCRIPTION OF THE REQUEST :
In working with the LinkedHashMap class a bit recently, I think I've found a few additional convenience methods that could prove useful. The following is a list:

1. A method to get the first node in the list.  After a quick glance at the code, this seems like it would simply involve accessing the 'header' entry.
2. A method to get the last, or eldest entry in the list.  If I'm not mistaken, this seems like it would be the 'header.before' entry.
3. A method to support reverse iteration.  Since it is a doubly-linked list, once again, easy modification.
4. A method, given a key, to start iteration at that key's point in the list.

JUSTIFICATION :
1. Once again, if I'm correct, the only way to get the last (eldest) entry is to traverse the whole list via the iterator.
2. Reverse iteration would be even more complex.
3. Starting iteration given a particular key would involve a sequential search in traversing the list.
(Review ID: 184177) 
======================================================================

                                    

Comments
EVALUATION

All of fancy (ordered) maps and sets (TreeMap/Set, LinkedHashMap/Set) are somewhat lacking in "navigation ability."  It would be straightforward to add these operations, but somewhat in conflict with the Collection Framework's "interface-based" philosophy.  If there is sufficient demand, we may do it anyway.

###@###.### 2003-06-19
                                     
2003-06-19
EVALUATION

It is worth investigating whether retrofitting
LinkedHashSet to implement the new Deque interface,
as was done with LinkedList, would be easy to do.
                                     
2005-08-05



Hardware and Software, Engineered to Work Together