152 |
|
* node of a bin list itself as a lock, using plain "synchronized" |
153 |
|
* locks. These save space and we can live with block-structured |
154 |
|
* lock/unlock operations. Using the first node of a list as a |
155 |
< |
* lock does not by itself suffice though: When a node is locked, |
155 |
> |
* lock does not by itself suffice though. When a node is locked, |
156 |
|
* any update must first validate that it is still the first node, |
157 |
|
* and retry if not. Because new nodes are always appended to |
158 |
|
* lists, once a node is first in a bin, it remains first until |
291 |
|
* special, and do not contain user keys or values. Otherwise, |
292 |
|
* keys are never null, and null val fields indicate that a node |
293 |
|
* is in the process of being deleted or created. For purposes of |
294 |
< |
* read-only, access, a key may be read before a val, but can only |
294 |
> |
* read-only access, a key may be read before a val, but can only |
295 |
|
* be used after checking val. (For an update operation, when a |
296 |
|
* lock is held on a node, order doesn't matter.) |
297 |
|
*/ |
422 |
|
return table; |
423 |
|
} |
424 |
|
|
425 |
< |
/* |
425 |
> |
/** |
426 |
|
* Reclassifies nodes in each bin to new table. Because we are |
427 |
|
* using power-of-two expansion, the elements from each bin must |
428 |
|
* either stay at same index, or move with a power of two |
771 |
|
* valid. |
772 |
|
* |
773 |
|
* Internal traversals directly access these fields, as in: |
774 |
< |
* {@code while (it.next != null) { process(nextKey); it.advance(); }} |
774 |
> |
* {@code while (it.next != null) { process(it.nextKey); it.advance(); }} |
775 |
|
* |
776 |
|
* Exported iterators (subclasses of ViewIterator) extract key, |
777 |
|
* value, or key-value pairs as return values of Iterator.next(), |
866 |
|
* @param initialCapacity The implementation performs internal |
867 |
|
* sizing to accommodate this many elements. |
868 |
|
* @throws IllegalArgumentException if the initial capacity of |
869 |
< |
* elements is negative. |
869 |
> |
* elements is negative |
870 |
|
*/ |
871 |
|
public ConcurrentHashMapV8(int initialCapacity) { |
872 |
|
if (initialCapacity < 0) |
898 |
|
* performs internal sizing to accommodate this many elements, |
899 |
|
* given the specified load factor. |
900 |
|
* @param loadFactor the load factor (table density) for |
901 |
< |
* establishing the initial table size. |
901 |
> |
* establishing the initial table size |
902 |
|
* @throws IllegalArgumentException if the initial capacity of |
903 |
|
* elements is negative or the load factor is nonpositive |
904 |
|
* |
918 |
|
* performs internal sizing to accommodate this many elements, |
919 |
|
* given the specified load factor. |
920 |
|
* @param loadFactor the load factor (table density) for |
921 |
< |
* establishing the initial table size. |
921 |
> |
* establishing the initial table size |
922 |
|
* @param concurrencyLevel the estimated number of concurrently |
923 |
|
* updating threads. The implementation may use this value as |
924 |
|
* a sizing hint. |
925 |
|
* @throws IllegalArgumentException if the initial capacity is |
926 |
|
* negative or the load factor or concurrencyLevel are |
927 |
< |
* nonpositive. |
927 |
> |
* nonpositive |
928 |
|
*/ |
929 |
|
public ConcurrentHashMapV8(int initialCapacity, |
930 |
|
float loadFactor, int concurrencyLevel) { |
980 |
|
* @param key possible key |
981 |
|
* @return {@code true} if and only if the specified object |
982 |
|
* is a key in this table, as determined by the |
983 |
< |
* {@code equals} method; {@code false} otherwise. |
983 |
> |
* {@code equals} method; {@code false} otherwise |
984 |
|
* @throws NullPointerException if the specified key is null |
985 |
|
*/ |
986 |
|
public boolean containsKey(Object key) { |
1117 |
|
* @param mappingFunction the function to compute a value |
1118 |
|
* @return the current (existing or computed) value associated with |
1119 |
|
* the specified key, or {@code null} if the computation |
1120 |
< |
* returned {@code null}. |
1120 |
> |
* returned {@code null} |
1121 |
|
* @throws NullPointerException if the specified key or mappingFunction |
1122 |
< |
* is null, |
1122 |
> |
* is null |
1123 |
|
* @throws IllegalStateException if the computation detectably |
1124 |
|
* attempts a recursive update to this map that would |
1125 |
< |
* otherwise never complete. |
1125 |
> |
* otherwise never complete |
1126 |
|
* @throws RuntimeException or Error if the mappingFunction does so, |
1127 |
< |
* in which case the mapping is left unestablished. |
1127 |
> |
* in which case the mapping is left unestablished |
1128 |
|
*/ |
1129 |
|
public V computeIfAbsent(K key, MappingFunction<? super K, ? extends V> mappingFunction) { |
1130 |
|
if (key == null || mappingFunction == null) |
1154 |
|
* @param mappingFunction the function to compute a value |
1155 |
|
* @return the current value associated with |
1156 |
|
* the specified key, or {@code null} if the computation |
1157 |
< |
* returned {@code null} and the value was not otherwise present. |
1157 |
> |
* returned {@code null} and the value was not otherwise present |
1158 |
|
* @throws NullPointerException if the specified key or mappingFunction |
1159 |
< |
* is null, |
1159 |
> |
* is null |
1160 |
|
* @throws IllegalStateException if the computation detectably |
1161 |
|
* attempts a recursive update to this map that would |
1162 |
< |
* otherwise never complete. |
1162 |
> |
* otherwise never complete |
1163 |
|
* @throws RuntimeException or Error if the mappingFunction does so, |
1164 |
< |
* in which case the mapping is unchanged. |
1164 |
> |
* in which case the mapping is unchanged |
1165 |
|
*/ |
1166 |
|
public V compute(K key, MappingFunction<? super K, ? extends V> mappingFunction) { |
1167 |
|
if (key == null || mappingFunction == null) |
1624 |
|
throws java.io.IOException, ClassNotFoundException { |
1625 |
|
s.defaultReadObject(); |
1626 |
|
this.segments = null; // unneeded |
1627 |
< |
// initalize transient final field |
1627 |
> |
// initialize transient final field |
1628 |
|
UNSAFE.putObjectVolatile(this, counterOffset, new LongAdder()); |
1629 |
|
this.targetCapacity = DEFAULT_CAPACITY; |
1630 |
|
|