ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/TreeMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/TreeMap.java (file contents):
Revision 1.36 by jsr166, Tue May 9 16:35:40 2006 UTC vs.
Revision 1.37 by dl, Tue May 9 18:17:08 2006 UTC

# Line 1117 | Line 1117 | public class TreeMap<K,V>
1117                  throw new IllegalStateException();
1118              if (modCount != expectedModCount)
1119                  throw new ConcurrentModificationException();
1120 +            // deleted entries are replaced by their successors
1121              if (lastReturned.left != null && lastReturned.right != null)
1122                  next = lastReturned;
1123              deleteEntry(lastReturned);
# Line 1581 | Line 1582 | public class TreeMap<K,V>
1582                  return e;
1583              }
1584  
1585 <            public void remove() {
1585 >            final void removeAscending() {
1586                  if (lastReturned == null)
1587                      throw new IllegalStateException();
1588                  if (m.modCount != expectedModCount)
1589                      throw new ConcurrentModificationException();
1590 +                // deleted entries are replaced by their successors
1591                  if (lastReturned.left != null && lastReturned.right != null)
1592                      next = lastReturned;
1593                  m.deleteEntry(lastReturned);
1592                expectedModCount++;
1594                  lastReturned = null;
1595 +                expectedModCount = m.modCount;
1596 +            }
1597 +
1598 +            final void removeDescending() {
1599 +                if (lastReturned == null)
1600 +                    throw new IllegalStateException();
1601 +                if (m.modCount != expectedModCount)
1602 +                    throw new ConcurrentModificationException();
1603 +                m.deleteEntry(lastReturned);
1604 +                lastReturned = null;
1605 +                expectedModCount = m.modCount;
1606              }
1607 +
1608          }
1609  
1610          final class SubMapEntryIterator extends SubMapIterator<Map.Entry<K,V>> {
# Line 1602 | Line 1615 | public class TreeMap<K,V>
1615              public Map.Entry<K,V> next() {
1616                  return nextEntry();
1617              }
1618 +            public void remove() {
1619 +                removeAscending();
1620 +            }
1621          }
1622  
1623          final class SubMapKeyIterator extends SubMapIterator<K> {
# Line 1612 | Line 1628 | public class TreeMap<K,V>
1628              public K next() {
1629                  return nextEntry().key;
1630              }
1631 +            public void remove() {
1632 +                removeAscending();
1633 +            }
1634          }
1635  
1636          final class DescendingSubMapEntryIterator extends SubMapIterator<Map.Entry<K,V>> {
# Line 1623 | Line 1642 | public class TreeMap<K,V>
1642              public Map.Entry<K,V> next() {
1643                  return prevEntry();
1644              }
1645 +            public void remove() {
1646 +                removeDescending();
1647 +            }
1648          }
1649  
1650          final class DescendingSubMapKeyIterator extends SubMapIterator<K> {
# Line 1633 | Line 1655 | public class TreeMap<K,V>
1655              public K next() {
1656                  return prevEntry().key;
1657              }
1658 +            public void remove() {
1659 +                removeDescending();
1660 +            }
1661          }
1662      }
1663  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines