RFR 8024709 : TreeMap.DescendingKeyIterator 'remove' confuses iterator position

Brent Christian brent.christian at oracle.com
Thu Oct 3 23:31:40 UTC 2013


Please review my fix for 8024709 : "TreeMap.DescendingKeyIterator 
'remove' confuses iterator position"

There are two possible code paths for performing a "descending" 
iteration over the elements in a TreeMep, depending on how the iteration 
is setup.

For instance,
   treemap.descendingKeySet().iterator();
will use a
   TreeMap.NavigableSubMap.DescendingSubMapIterator
This code correctly handles Iterator.remove().

On the other hand,
   treemap.navigableKeySet().descendingIterator();
will use a
   TreeMap.DescendingKeyIterator.
This code does not correctly handle remove(), and results in a 
"confused" iterator.


TreeMap.DescendingKeyIterator should override remove() with code
similar to that in 
TreeMap.NavigableSubMap.SubMapIterator.removeDescending().


Bug report:
https://bugs.openjdk.java.net/browse/JDK-8024709

Webrev:
http://cr.openjdk.java.net/~bchristi/8024709/webrev.00/


An automated test run has not turned up any problems.

Thanks,
-Brent




More information about the core-libs-dev mailing list