85 |
|
* <p><em>jsr166e note: This class is a candidate replacement for |
86 |
|
* java.util.concurrent.ConcurrentHashMap.<em> |
87 |
|
* |
88 |
< |
* @since 1.5 |
88 |
> |
* @since 1.8 |
89 |
|
* @author Doug Lea |
90 |
|
* @param <K> the type of keys maintained by this map |
91 |
|
* @param <V> the type of mapped values |
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 |
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 |
– |
* |
905 |
– |
* @since 1.6 |
904 |
|
*/ |
905 |
|
public ConcurrentHashMapV8(int initialCapacity, float loadFactor) { |
906 |
|
this(initialCapacity, loadFactor, 1); |
916 |
|
* performs internal sizing to accommodate this many elements, |
917 |
|
* given the specified load factor. |
918 |
|
* @param loadFactor the load factor (table density) for |
919 |
< |
* establishing the initial table size. |
919 |
> |
* establishing the initial table size |
920 |
|
* @param concurrencyLevel the estimated number of concurrently |
921 |
|
* updating threads. The implementation may use this value as |
922 |
|
* a sizing hint. |
923 |
|
* @throws IllegalArgumentException if the initial capacity is |
924 |
|
* negative or the load factor or concurrencyLevel are |
925 |
< |
* nonpositive. |
925 |
> |
* nonpositive |
926 |
|
*/ |
927 |
|
public ConcurrentHashMapV8(int initialCapacity, |
928 |
|
float loadFactor, int concurrencyLevel) { |
978 |
|
* @param key possible key |
979 |
|
* @return {@code true} if and only if the specified object |
980 |
|
* is a key in this table, as determined by the |
981 |
< |
* {@code equals} method; {@code false} otherwise. |
981 |
> |
* {@code equals} method; {@code false} otherwise |
982 |
|
* @throws NullPointerException if the specified key is null |
983 |
|
*/ |
984 |
|
public boolean containsKey(Object key) { |
1115 |
|
* @param mappingFunction the function to compute a value |
1116 |
|
* @return the current (existing or computed) value associated with |
1117 |
|
* the specified key, or {@code null} if the computation |
1118 |
< |
* returned {@code null}. |
1118 |
> |
* returned {@code null} |
1119 |
|
* @throws NullPointerException if the specified key or mappingFunction |
1120 |
< |
* is null, |
1120 |
> |
* is null |
1121 |
|
* @throws IllegalStateException if the computation detectably |
1122 |
|
* attempts a recursive update to this map that would |
1123 |
< |
* otherwise never complete. |
1123 |
> |
* otherwise never complete |
1124 |
|
* @throws RuntimeException or Error if the mappingFunction does so, |
1125 |
< |
* in which case the mapping is left unestablished. |
1125 |
> |
* in which case the mapping is left unestablished |
1126 |
|
*/ |
1127 |
|
public V computeIfAbsent(K key, MappingFunction<? super K, ? extends V> mappingFunction) { |
1128 |
|
if (key == null || mappingFunction == null) |
1152 |
|
* @param mappingFunction the function to compute a value |
1153 |
|
* @return the current value associated with |
1154 |
|
* the specified key, or {@code null} if the computation |
1155 |
< |
* returned {@code null} and the value was not otherwise present. |
1155 |
> |
* returned {@code null} and the value was not otherwise present |
1156 |
|
* @throws NullPointerException if the specified key or mappingFunction |
1157 |
< |
* is null, |
1157 |
> |
* is null |
1158 |
|
* @throws IllegalStateException if the computation detectably |
1159 |
|
* attempts a recursive update to this map that would |
1160 |
< |
* otherwise never complete. |
1160 |
> |
* otherwise never complete |
1161 |
|
* @throws RuntimeException or Error if the mappingFunction does so, |
1162 |
< |
* in which case the mapping is unchanged. |
1162 |
> |
* in which case the mapping is unchanged |
1163 |
|
*/ |
1164 |
|
public V compute(K key, MappingFunction<? super K, ? extends V> mappingFunction) { |
1165 |
|
if (key == null || mappingFunction == null) |
1622 |
|
throws java.io.IOException, ClassNotFoundException { |
1623 |
|
s.defaultReadObject(); |
1624 |
|
this.segments = null; // unneeded |
1625 |
< |
// initalize transient final field |
1625 |
> |
// initialize transient final field |
1626 |
|
UNSAFE.putObjectVolatile(this, counterOffset, new LongAdder()); |
1627 |
|
this.targetCapacity = DEFAULT_CAPACITY; |
1628 |
|
|