1 |
|
/* |
2 |
|
* %W% %E% |
3 |
|
* |
4 |
< |
* Copyright 2004 Sun Microsystems, Inc. All rights reserved. |
4 |
> |
* Copyright 2005 Sun Microsystems, Inc. All rights reserved. |
5 |
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
6 |
|
*/ |
7 |
|
|
351 |
|
// Offload comparator-based version for sake of performance |
352 |
|
if (comparator != null) |
353 |
|
return getEntryUsingComparator(key); |
354 |
< |
Comparable<K> k = (Comparable<K>) key; |
354 |
> |
Comparable<? super K> k = (Comparable<? super K>) key; |
355 |
|
Entry<K,V> p = root; |
356 |
|
while (p != null) { |
357 |
|
int cmp = k.compareTo(p.key); |
556 |
|
Entry<K,V> t = root; |
557 |
|
|
558 |
|
if (t == null) { |
559 |
+ |
if (key == null) { |
560 |
+ |
if (comparator == null) |
561 |
+ |
throw new NullPointerException(); |
562 |
+ |
comparator.compare(key, key); |
563 |
+ |
} |
564 |
|
incrementSize(); |
565 |
|
root = new Entry<K,V>(key, value, null); |
566 |
|
return null; |
879 |
|
private transient Set<Map.Entry<K,V>> descendingEntrySet = null; |
880 |
|
private transient Set<K> descendingKeySet = null; |
881 |
|
|
877 |
– |
transient Set<K> keySet = null; // XXX remove when integrated |
878 |
– |
transient Collection<V> values = null; // XXX remove when integrated |
879 |
– |
|
882 |
|
/** |
883 |
|
* Returns a Set view of the keys contained in this map. The set's |
884 |
|
* iterator will return the keys in ascending order. The set is backed by |
1343 |
|
TreeMap.Entry<K,V> e = fromStart ? getFirstEntry() : getCeilingEntry(fromKey); |
1344 |
|
K first = key(e); |
1345 |
|
if (!toEnd && compare(first, toKey) >= 0) |
1346 |
< |
throw(new NoSuchElementException()); |
1346 |
> |
throw new NoSuchElementException(); |
1347 |
|
return first; |
1348 |
|
} |
1349 |
|
|
1351 |
|
TreeMap.Entry<K,V> e = toEnd ? getLastEntry() : getLowerEntry(toKey); |
1352 |
|
K last = key(e); |
1353 |
|
if (!fromStart && compare(last, fromKey) < 0) |
1354 |
< |
throw(new NoSuchElementException()); |
1354 |
> |
throw new NoSuchElementException(); |
1355 |
|
return last; |
1356 |
|
} |
1357 |
|
|
1765 |
|
* Compares two keys using the correct comparison method for this TreeMap. |
1766 |
|
*/ |
1767 |
|
private int compare(K k1, K k2) { |
1768 |
< |
return (comparator==null ? ((Comparable</*-*/K>)k1).compareTo(k2) |
1769 |
< |
: comparator.compare((K)k1, (K)k2)); |
1768 |
> |
return comparator==null ? ((Comparable<? super K>)k1).compareTo(k2) |
1769 |
> |
: comparator.compare(k1, k2); |
1770 |
|
} |
1771 |
|
|
1772 |
|
/** |
2198 |
|
} |
2199 |
|
|
2200 |
|
/** Intended to be called only from TreeSet.addAll **/ |
2201 |
< |
void addAllForTreeSet(SortedSet<Map.Entry<K,V>> set, V defaultVal) { |
2201 |
> |
void addAllForTreeSet(SortedSet<? extends K> set, V defaultVal) { |
2202 |
|
try { |
2203 |
|
buildFromSorted(set.size(), set.iterator(), null, defaultVal); |
2204 |
|
} catch (java.io.IOException cannotHappen) { |