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); |
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>> { |
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> { |
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>> { |
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> { |
1655 |
|
public K next() { |
1656 |
|
return prevEntry().key; |
1657 |
|
} |
1658 |
+ |
public void remove() { |
1659 |
+ |
removeDescending(); |
1660 |
+ |
} |
1661 |
|
} |
1662 |
|
} |
1663 |
|
|