31 |
|
* <i>is</i> well-defined even if its ordering is inconsistent with equals; it |
32 |
|
* just fails to obey the general contract of the <tt>Map</tt> interface. |
33 |
|
* |
34 |
< |
* <p><b>Note that this implementation is not synchronized.</b> If multiple |
35 |
< |
* threads access a map concurrently, and at least one of the threads modifies |
36 |
< |
* the map structurally, it <i>must</i> be synchronized externally. (A |
37 |
< |
* structural modification is any operation that adds or deletes one or more |
38 |
< |
* mappings; merely changing the value associated with an existing key is not |
39 |
< |
* a structural modification.) This is typically accomplished by |
40 |
< |
* synchronizing on some object that naturally encapsulates the map. If no |
41 |
< |
* such object exists, the map should be "wrapped" using the |
42 |
< |
* <tt>Collections.synchronizedMap</tt> method. This is best done at creation |
43 |
< |
* time, to prevent accidental unsynchronized access to the map: |
44 |
< |
* <pre> |
45 |
< |
* Map m = Collections.synchronizedMap(new TreeMap(...)); |
46 |
< |
* </pre> |
34 |
> |
* <p><strong>Note that this implementation is not synchronized.</strong> |
35 |
> |
* If multiple threads access a map concurrently, and at least one of the |
36 |
> |
* threads modifies the map structurally, it <i>must</i> be synchronized |
37 |
> |
* externally. (A structural modification is any operation that adds or |
38 |
> |
* deletes one or more mappings; merely changing the value associated |
39 |
> |
* with an existing key is not a structural modification.) This is |
40 |
> |
* typically accomplished by synchronizing on some object that naturally |
41 |
> |
* encapsulates the map. |
42 |
> |
* If no such object exists, the map should be "wrapped" using the |
43 |
> |
* {@link Collections#synchronizedSortedMap Collections.synchronizedSortedMap} |
44 |
> |
* method. This is best done at creation time, to prevent accidental |
45 |
> |
* unsynchronized access to the map: <pre> |
46 |
> |
* SortedMap m = Collections.synchronizedSortedMap(new TreeMap(...));</pre> |
47 |
|
* |
48 |
|
* <p>The iterators returned by the <tt>iterator</tt> method of the collections |
49 |
|
* returned by all of this class's "collection view methods" are |
83 |
|
* @see Comparable |
84 |
|
* @see Comparator |
85 |
|
* @see Collection |
86 |
– |
* @see Collections#synchronizedMap(Map) |
86 |
|
* @since 1.2 |
87 |
|
*/ |
88 |
|
|
540 |
|
Entry<K,V> t = root; |
541 |
|
|
542 |
|
if (t == null) { |
543 |
< |
if (key == null) { |
544 |
< |
if (comparator == null) |
545 |
< |
throw new NullPointerException(); |
546 |
< |
comparator.compare(key, key); |
547 |
< |
} |
543 |
> |
// TBD |
544 |
> |
// if (key == null) { |
545 |
> |
// if (comparator == null) |
546 |
> |
// throw new NullPointerException(); |
547 |
> |
// comparator.compare(key, key); |
548 |
> |
// } |
549 |
|
incrementSize(); |
550 |
|
root = new Entry<K,V>(key, value, null); |
551 |
|
return null; |