Returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteratio
()
| 1658 | * @return a set view of the mappings contained in this map. |
| 1659 | */ |
| 1660 | public Set entrySet() |
| 1661 | { |
| 1662 | if (_entry_set[ _KEY ] == null) |
| 1663 | { |
| 1664 | _entry_set[ _KEY ] = new AbstractSet() |
| 1665 | { |
| 1666 | public Iterator iterator() |
| 1667 | { |
| 1668 | return new BinaryTreeIterator(_KEY) |
| 1669 | { |
| 1670 | protected Object doGetNext() |
| 1671 | { |
| 1672 | return _last_returned_node; |
| 1673 | } |
| 1674 | }; |
| 1675 | } |
| 1676 | |
| 1677 | public boolean contains(Object o) |
| 1678 | { |
| 1679 | if (!(o instanceof Map.Entry)) |
| 1680 | { |
| 1681 | return false; |
| 1682 | } |
| 1683 | Map.Entry entry = ( Map.Entry ) o; |
| 1684 | Object value = entry.getValue(); |
| 1685 | Node node = lookup(( Comparable ) entry.getKey(), |
| 1686 | _KEY); |
| 1687 | |
| 1688 | return (node != null) |
| 1689 | && node.getData(_VALUE).equals(value); |
| 1690 | } |
| 1691 | |
| 1692 | public boolean remove(Object o) |
| 1693 | { |
| 1694 | if (!(o instanceof Map.Entry)) |
| 1695 | { |
| 1696 | return false; |
| 1697 | } |
| 1698 | Map.Entry entry = ( Map.Entry ) o; |
| 1699 | Object value = entry.getValue(); |
| 1700 | Node node = lookup(( Comparable ) entry.getKey(), |
| 1701 | _KEY); |
| 1702 | |
| 1703 | if ((node != null) && node.getData(_VALUE).equals(value)) |
| 1704 | { |
| 1705 | doRedBlackDelete(node); |
| 1706 | return true; |
| 1707 | } |
| 1708 | return false; |
| 1709 | } |
| 1710 | |
| 1711 | public int size() |
| 1712 | { |
| 1713 | return BinaryTree.this.size(); |
| 1714 | } |
| 1715 | |
| 1716 | public void clear() |
| 1717 | { |
no outgoing calls