6 |
|
*/ |
7 |
|
|
8 |
|
package java.util; |
9 |
+ |
import java.util.*; // for javadoc (till 6280605 is fixed) |
10 |
|
|
11 |
|
/** |
12 |
|
* A Red-Black tree based {@link NavigableMap} implementation. |
217 |
|
* specified value. More formally, returns <tt>true</tt> if and only if |
218 |
|
* this map contains at least one mapping to a value <tt>v</tt> such |
219 |
|
* that <tt>(value==null ? v==null : value.equals(v))</tt>. This |
220 |
< |
* operation requires time linear in the map size. |
220 |
> |
* operation will probably require time linear in the map size for |
221 |
> |
* most implementations. |
222 |
|
* |
223 |
|
* @param value value whose presence in this map is to be tested |
224 |
|
* @return <tt>true</tt> if a mapping to <tt>value</tt> exists; |
255 |
|
* <tt>null</tt> if the map contains no mapping for the key. A return |
256 |
|
* value of <tt>null</tt> does not <i>necessarily</i> indicate that the |
257 |
|
* map contains no mapping for the key; it's also possible that the map |
258 |
< |
* explicitly maps the key to <tt>null</tt>. The {@link #containsKey} |
259 |
< |
* operation may be used to distinguish these two cases. |
258 |
> |
* explicitly maps the key to <tt>null</tt>. The {@link #containsKey |
259 |
> |
* containsKey} operation may be used to distinguish these two cases. |
260 |
|
* |
261 |
|
* @param key key whose associated value is to be returned |
262 |
|
* @return the value to which this map maps the specified key, or |
521 |
|
|
522 |
|
/** |
523 |
|
* Associates the specified value with the specified key in this map. |
524 |
< |
* If the map previously contained a mapping for this key, the old |
524 |
> |
* If the map previously contained a mapping for the key, the old |
525 |
|
* value is replaced. |
526 |
|
* |
527 |
|
* @param key key with which the specified value is to be associated |
1068 |
|
} |
1069 |
|
|
1070 |
|
public boolean containsKey(Object key) { |
1071 |
< |
return inRange((K) key) && TreeMap.this.containsKey(key); |
1071 |
> |
return inRange(key) && TreeMap.this.containsKey(key); |
1072 |
|
} |
1073 |
|
|
1074 |
|
public V get(Object key) { |
1075 |
< |
if (!inRange((K) key)) |
1075 |
> |
if (!inRange(key)) |
1076 |
|
return null; |
1077 |
|
return TreeMap.this.get(key); |
1078 |
|
} |
1084 |
|
} |
1085 |
|
|
1086 |
|
public V remove(Object key) { |
1087 |
< |
if (!inRange((K) key)) |
1087 |
> |
if (!inRange(key)) |
1088 |
|
return null; |
1089 |
|
return TreeMap.this.remove(key); |
1090 |
|
} |
1353 |
|
return navigableTailMap(fromKey); |
1354 |
|
} |
1355 |
|
|
1356 |
< |
private boolean inRange(K key) { |
1356 |
> |
private boolean inRange(Object key) { |
1357 |
|
return (fromStart || compare(key, fromKey) >= 0) && |
1358 |
|
(toEnd || compare(key, toKey) < 0); |
1359 |
|
} |
1360 |
|
|
1361 |
|
// This form allows the high endpoint (as well as all legit keys) |
1362 |
< |
private boolean inRange2(K key) { |
1362 |
> |
private boolean inRange2(Object key) { |
1363 |
|
return (fromStart || compare(key, fromKey) >= 0) && |
1364 |
|
(toEnd || compare(key, toKey) <= 0); |
1365 |
|
} |
1521 |
|
} |
1522 |
|
|
1523 |
|
/** |
1524 |
< |
* Test two values for equality. Differs from o1.equals(o2) only in |
1524 |
> |
* Test two values for equality. Differs from o1.equals(o2) only in |
1525 |
|
* that it copes with <tt>null</tt> o1 properly. |
1526 |
|
*/ |
1527 |
|
private static boolean valEquals(Object o1, Object o2) { |