Submitted On 27-JUN-2003
toddwright
Wait, scratch that first comment -- it's already ordered
with the eldest at the front, so you can use the iterator
as-is for most LRU applications.
A reverse iterator would allow the client to easily list the
most-popular entries (or, if in insertion order, the most
recent insertions).
Submitted On 27-JUN-2003
toddwright
One argument for the reverse iterator is that it allows the
LinkedHashMap's "removeEldestEntry(..)" method to remove one
or more old entries, instead of just the eldest. For
example, we may want to remove the eldest half of the
entries, or we really want to remove the second-eldest entry
(e.g. in a cache with a few non-evictable entries). To do
this now requires a copy of the values into a list/array
that supports reverse iteration.
I see the API philosophy conflict. If you follow the List
convention, this would require a new "listIterator()"
method, or a LinkedList view of the "values()". At worst
these could be hidden from the interface, similar to
ArrayList's "trimToSize()".
Submitted On 11-JUL-2003
Osen
And a method to insert an entry at a given position between
the existing entries would also be useful. Currently there's
only the put-method which inserts at the end.
Submitted On 03-JAN-2005
theshade
I
Submitted On 03-JAN-2005
theshade
Comment got lost when I logged in... again: I'd find a reverse iterator useful as well. I'm using a LinkedHashSet to keep track of visited items (highlighted in a different color). I want to use the set to display the last X visited items. With a doubly linked list this would be trivial, but there's no such method in LinkedHashSet. The speed of contains() speed is important as the set grows very large.
Submitted On 07-AUG-2005
barryg2004
I'd also like to see the Set returned by LinkedHashMap.keySet implement the "java.uil.SortedSet" interface. At present the type returned is: HashMap.KeySet. i.e. the iteration order is implied rather than guaranteed.
Submitted On 10-DEC-2007
I would prefer to iterate the list both insertion order (as currently) and reverse insertion order, but lacking that, it would be nice, at the very least, to specify iteration order on construction as insertion (like today) or reverse insertion order.
Submitted On 04-JUN-2009
It would be very useful to be possible to iterate starting with an arbitrary element.
Submitted On 04-JUN-2009
It would be very useful to be possible to iterate starting with an arbitrary element.
Submitted On 26-OCT-2009
msenesi
I would absolutely appreciate these features.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|