5 |
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
6 |
|
*/ |
7 |
|
|
8 |
< |
package java.util; |
8 |
> |
package java.util; |
9 |
|
|
10 |
|
|
11 |
|
/** |
559 |
|
incrementSize(); |
560 |
|
root = new Entry<K,V>(key, value, null); |
561 |
|
return null; |
562 |
< |
} |
562 |
> |
} |
563 |
|
|
564 |
|
while (true) { |
565 |
|
int cmp = compare(key, t.key); |
658 |
|
/** |
659 |
|
* Returns a key-value mapping associated with the least |
660 |
|
* key in this map, or <tt>null</tt> if the map is empty. |
661 |
< |
* |
662 |
< |
* @return an Entry with least key, or <tt>null</tt> |
661 |
> |
* |
662 |
> |
* @return an Entry with least key, or <tt>null</tt> |
663 |
|
* if the map is empty. |
664 |
|
*/ |
665 |
|
public Map.Entry<K,V> firstEntry() { |
670 |
|
/** |
671 |
|
* Returns a key-value mapping associated with the greatest |
672 |
|
* key in this map, or <tt>null</tt> if the map is empty. |
673 |
< |
* |
673 |
> |
* |
674 |
|
* @return an Entry with greatest key, or <tt>null</tt> |
675 |
|
* if the map is empty. |
676 |
|
*/ |
682 |
|
/** |
683 |
|
* Removes and returns a key-value mapping associated with |
684 |
|
* the least key in this map, or <tt>null</tt> if the map is empty. |
685 |
< |
* |
685 |
> |
* |
686 |
|
* @return the removed first entry of this map, or <tt>null</tt> |
687 |
|
* if the map is empty. |
688 |
|
*/ |
689 |
|
public Map.Entry<K,V> pollFirstEntry() { |
690 |
|
Entry<K,V> p = getFirstEntry(); |
691 |
< |
if (p == null) |
691 |
> |
if (p == null) |
692 |
|
return null; |
693 |
|
Map.Entry result = new AbstractMap.SimpleImmutableEntry(p); |
694 |
|
deleteEntry(p); |
698 |
|
/** |
699 |
|
* Removes and returns a key-value mapping associated with |
700 |
|
* the greatest key in this map, or <tt>null</tt> if the map is empty. |
701 |
< |
* |
701 |
> |
* |
702 |
|
* @return the removed last entry of this map, or <tt>null</tt> |
703 |
|
* if the map is empty. |
704 |
|
*/ |
705 |
|
public Map.Entry<K,V> pollLastEntry() { |
706 |
|
Entry<K,V> p = getLastEntry(); |
707 |
< |
if (p == null) |
707 |
> |
if (p == null) |
708 |
|
return null; |
709 |
|
Map.Entry result = new AbstractMap.SimpleImmutableEntry(p); |
710 |
|
deleteEntry(p); |
714 |
|
/** |
715 |
|
* Returns a key-value mapping associated with the least key |
716 |
|
* greater than or equal to the given key, or <tt>null</tt> if |
717 |
< |
* there is no such entry. |
718 |
< |
* |
717 |
> |
* there is no such entry. |
718 |
> |
* |
719 |
|
* @param key the key. |
720 |
|
* @return an Entry associated with ceiling of given key, or |
721 |
|
* <tt>null</tt> if there is no such Entry. |
734 |
|
/** |
735 |
|
* Returns least key greater than or equal to the given key, or |
736 |
|
* <tt>null</tt> if there is no such key. |
737 |
< |
* |
737 |
> |
* |
738 |
|
* @param key the key. |
739 |
|
* @return the ceiling key, or <tt>null</tt> |
740 |
|
* if there is no such key. |
754 |
|
/** |
755 |
|
* Returns a key-value mapping associated with the greatest key |
756 |
|
* less than or equal to the given key, or <tt>null</tt> if there |
757 |
< |
* is no such entry. |
758 |
< |
* |
757 |
> |
* is no such entry. |
758 |
> |
* |
759 |
|
* @param key the key. |
760 |
|
* @return an Entry associated with floor of given key, or <tt>null</tt> |
761 |
|
* if there is no such Entry. |
774 |
|
* Returns the greatest key |
775 |
|
* less than or equal to the given key, or <tt>null</tt> if there |
776 |
|
* is no such key. |
777 |
< |
* |
777 |
> |
* |
778 |
|
* @param key the key. |
779 |
|
* @return the floor of given key, or <tt>null</tt> if there is no |
780 |
|
* such key. |
792 |
|
/** |
793 |
|
* Returns a key-value mapping associated with the least key |
794 |
|
* strictly greater than the given key, or <tt>null</tt> if there |
795 |
< |
* is no such entry. |
796 |
< |
* |
795 |
> |
* is no such entry. |
796 |
> |
* |
797 |
|
* @param key the key. |
798 |
|
* @return an Entry with least key greater than the given key, or |
799 |
|
* <tt>null</tt> if there is no such Entry. |
811 |
|
/** |
812 |
|
* Returns the least key strictly greater than the given key, or |
813 |
|
* <tt>null</tt> if there is no such key. |
814 |
< |
* |
814 |
> |
* |
815 |
|
* @param key the key. |
816 |
|
* @return the least key greater than the given key, or |
817 |
|
* <tt>null</tt> if there is no such key. |
829 |
|
/** |
830 |
|
* Returns a key-value mapping associated with the greatest |
831 |
|
* key strictly less than the given key, or <tt>null</tt> if there is no |
832 |
< |
* such entry. |
833 |
< |
* |
832 |
> |
* such entry. |
833 |
> |
* |
834 |
|
* @param key the key. |
835 |
|
* @return an Entry with greatest key less than the given |
836 |
|
* key, or <tt>null</tt> if there is no such Entry. |
848 |
|
/** |
849 |
|
* Returns the greatest key strictly less than the given key, or |
850 |
|
* <tt>null</tt> if there is no such key. |
851 |
< |
* |
851 |
> |
* |
852 |
|
* @param key the key. |
853 |
|
* @return the greatest key less than the given |
854 |
|
* key, or <tt>null</tt> if there is no such key. |
872 |
|
*/ |
873 |
|
private transient Set<Map.Entry<K,V>> entrySet = null; |
874 |
|
private transient Set<Map.Entry<K,V>> descendingEntrySet = null; |
875 |
< |
private transient Set<K> descendingKeySet = null; |
875 |
> |
private transient Set<K> descendingKeySet = null; |
876 |
|
|
877 |
|
transient Set<K> keySet = null; // XXX remove when integrated |
878 |
|
transient Collection<V> values = null; // XXX remove when integrated |
898 |
|
public Iterator<K> iterator() { |
899 |
|
return new KeyIterator(getFirstEntry()); |
900 |
|
} |
901 |
< |
|
901 |
> |
|
902 |
|
public int size() { |
903 |
|
return TreeMap.this.size(); |
904 |
|
} |
905 |
< |
|
905 |
> |
|
906 |
|
public boolean contains(Object o) { |
907 |
|
return containsKey(o); |
908 |
|
} |
909 |
< |
|
909 |
> |
|
910 |
|
public boolean remove(Object o) { |
911 |
|
int oldSize = size; |
912 |
|
TreeMap.this.remove(o); |
913 |
|
return size != oldSize; |
914 |
|
} |
915 |
< |
|
915 |
> |
|
916 |
|
public void clear() { |
917 |
|
TreeMap.this.clear(); |
918 |
|
} |
940 |
|
public Iterator<V> iterator() { |
941 |
|
return new ValueIterator(getFirstEntry()); |
942 |
|
} |
943 |
< |
|
943 |
> |
|
944 |
|
public int size() { |
945 |
|
return TreeMap.this.size(); |
946 |
|
} |
947 |
< |
|
947 |
> |
|
948 |
|
public boolean contains(Object o) { |
949 |
|
for (Entry<K,V> e = getFirstEntry(); e != null; e = successor(e)) |
950 |
|
if (valEquals(e.getValue(), o)) |
951 |
|
return true; |
952 |
|
return false; |
953 |
|
} |
954 |
< |
|
954 |
> |
|
955 |
|
public boolean remove(Object o) { |
956 |
|
for (Entry<K,V> e = getFirstEntry(); e != null; e = successor(e)) { |
957 |
|
if (valEquals(e.getValue(), o)) { |
961 |
|
} |
962 |
|
return false; |
963 |
|
} |
964 |
< |
|
964 |
> |
|
965 |
|
public void clear() { |
966 |
|
TreeMap.this.clear(); |
967 |
|
} |
990 |
|
public Iterator<Map.Entry<K,V>> iterator() { |
991 |
|
return new EntryIterator(getFirstEntry()); |
992 |
|
} |
993 |
< |
|
993 |
> |
|
994 |
|
public boolean contains(Object o) { |
995 |
|
if (!(o instanceof Map.Entry)) |
996 |
|
return false; |
999 |
|
Entry<K,V> p = getEntry(entry.getKey()); |
1000 |
|
return p != null && valEquals(p.getValue(), value); |
1001 |
|
} |
1002 |
< |
|
1002 |
> |
|
1003 |
|
public boolean remove(Object o) { |
1004 |
|
if (!(o instanceof Map.Entry)) |
1005 |
|
return false; |
1012 |
|
} |
1013 |
|
return false; |
1014 |
|
} |
1015 |
< |
|
1015 |
> |
|
1016 |
|
public int size() { |
1017 |
|
return TreeMap.this.size(); |
1018 |
|
} |
1019 |
< |
|
1019 |
> |
|
1020 |
|
public void clear() { |
1021 |
|
TreeMap.this.clear(); |
1022 |
|
} |
1034 |
|
* operations. It does not support the <tt>add</tt> or |
1035 |
|
* <tt>addAll</tt> operations. |
1036 |
|
* |
1037 |
< |
* @return a set view of the mappings contained in this map, in |
1037 |
> |
* @return a set view of the mappings contained in this map, in |
1038 |
|
* descending key order |
1039 |
|
* @see Map.Entry |
1040 |
|
*/ |
1354 |
|
} |
1355 |
|
|
1356 |
|
public Map.Entry<K,V> firstEntry() { |
1357 |
< |
TreeMap.Entry<K,V> e = fromStart ? |
1357 |
> |
TreeMap.Entry<K,V> e = fromStart ? |
1358 |
|
getFirstEntry() : getCeilingEntry(fromKey); |
1359 |
|
if (e == null || (!toEnd && compare(e.key, toKey) >= 0)) |
1360 |
|
return null; |
1362 |
|
} |
1363 |
|
|
1364 |
|
public Map.Entry<K,V> lastEntry() { |
1365 |
< |
TreeMap.Entry<K,V> e = toEnd ? |
1365 |
> |
TreeMap.Entry<K,V> e = toEnd ? |
1366 |
|
getLastEntry() : getLowerEntry(toKey); |
1367 |
|
if (e == null || (!fromStart && compare(e.key, fromKey) < 0)) |
1368 |
|
return null; |
1370 |
|
} |
1371 |
|
|
1372 |
|
public Map.Entry<K,V> pollFirstEntry() { |
1373 |
< |
TreeMap.Entry<K,V> e = fromStart ? |
1373 |
> |
TreeMap.Entry<K,V> e = fromStart ? |
1374 |
|
getFirstEntry() : getCeilingEntry(fromKey); |
1375 |
|
if (e == null || (!toEnd && compare(e.key, toKey) >= 0)) |
1376 |
|
return null; |
1380 |
|
} |
1381 |
|
|
1382 |
|
public Map.Entry<K,V> pollLastEntry() { |
1383 |
< |
TreeMap.Entry<K,V> e = toEnd ? |
1383 |
> |
TreeMap.Entry<K,V> e = toEnd ? |
1384 |
|
getLastEntry() : getLowerEntry(toKey); |
1385 |
|
if (e == null || (!fromStart && compare(e.key, fromKey) < 0)) |
1386 |
|
return null; |
1523 |
|
} |
1524 |
|
|
1525 |
|
private transient Set<Map.Entry<K,V>> descendingEntrySetView = null; |
1526 |
< |
private transient Set<K> descendingKeySetView = null; |
1526 |
> |
private transient Set<K> descendingKeySetView = null; |
1527 |
|
|
1528 |
|
public Set<Map.Entry<K,V>> descendingEntrySet() { |
1529 |
|
Set<Map.Entry<K,V>> es = descendingEntrySetView; |
1547 |
|
public Iterator<K> iterator() { |
1548 |
|
return new Iterator<K>() { |
1549 |
|
private Iterator<Entry<K,V>> i = descendingEntrySet().iterator(); |
1550 |
< |
|
1550 |
> |
|
1551 |
|
public boolean hasNext() { return i.hasNext(); } |
1552 |
|
public K next() { return i.next().getKey(); } |
1553 |
|
public void remove() { i.remove(); } |
1554 |
|
}; |
1555 |
|
} |
1556 |
< |
|
1556 |
> |
|
1557 |
|
public int size() { |
1558 |
|
return SubMap.this.size(); |
1559 |
|
} |
1560 |
< |
|
1560 |
> |
|
1561 |
|
public boolean contains(Object k) { |
1562 |
|
return SubMap.this.containsKey(k); |
1563 |
|
} |