1785 |
|
} |
1786 |
|
} |
1787 |
|
if (len != 0) { |
1788 |
< |
if (len > 1) |
1788 |
> |
if (len > 1) { |
1789 |
|
addCount(delta, len); |
1790 |
+ |
delta = 0L; |
1791 |
+ |
} |
1792 |
|
break; |
1793 |
|
} |
1794 |
|
} |
1977 |
|
} |
1978 |
|
} |
1979 |
|
|
1980 |
< |
/* |
1980 |
> |
/** |
1981 |
|
* Moves and/or copies the nodes in each bin to new table. See |
1982 |
|
* above for explanation. |
1983 |
|
*/ |
2894 |
|
* course only appropriate if it is acceptable to use the same |
2895 |
|
* value for all additions from this view. |
2896 |
|
* |
2897 |
< |
* @param mappedValue the mapped value to use for any |
2896 |
< |
* additions. |
2897 |
> |
* @param mappedValue the mapped value to use for any additions |
2898 |
|
* @return the set view |
2899 |
|
* @throws NullPointerException if the mappedValue is null |
2900 |
|
*/ |
3372 |
|
* of each (key, value). |
3373 |
|
* |
3374 |
|
* @param transformer a function returning the transformation |
3375 |
< |
* for an element, or null of there is no transformation (in |
3376 |
< |
* which case the action is not applied). |
3375 |
> |
* for an element, or null if there is no transformation (in |
3376 |
> |
* which case the action is not applied) |
3377 |
|
* @param action the action |
3378 |
|
*/ |
3379 |
|
@SuppressWarnings("unchecked") public <U> void forEachSequentially |
3416 |
|
* combine values, or null if none. |
3417 |
|
* |
3418 |
|
* @param transformer a function returning the transformation |
3419 |
< |
* for an element, or null of there is no transformation (in |
3420 |
< |
* which case it is not combined). |
3419 |
> |
* for an element, or null if there is no transformation (in |
3420 |
> |
* which case it is not combined) |
3421 |
|
* @param reducer a commutative associative combining function |
3422 |
|
* @return the result of accumulating the given transformation |
3423 |
|
* of all (key, value) pairs |
3529 |
|
* of each key. |
3530 |
|
* |
3531 |
|
* @param transformer a function returning the transformation |
3532 |
< |
* for an element, or null of there is no transformation (in |
3533 |
< |
* which case the action is not applied). |
3532 |
> |
* for an element, or null if there is no transformation (in |
3533 |
> |
* which case the action is not applied) |
3534 |
|
* @param action the action |
3535 |
|
*/ |
3536 |
|
@SuppressWarnings("unchecked") public <U> void forEachKeySequentially |
3594 |
|
* null if none. |
3595 |
|
* |
3596 |
|
* @param transformer a function returning the transformation |
3597 |
< |
* for an element, or null of there is no transformation (in |
3598 |
< |
* which case it is not combined). |
3597 |
> |
* for an element, or null if there is no transformation (in |
3598 |
> |
* which case it is not combined) |
3599 |
|
* @param reducer a commutative associative combining function |
3600 |
|
* @return the result of accumulating the given transformation |
3601 |
|
* of all keys |
3707 |
|
* of each value. |
3708 |
|
* |
3709 |
|
* @param transformer a function returning the transformation |
3710 |
< |
* for an element, or null of there is no transformation (in |
3711 |
< |
* which case the action is not applied). |
3710 |
> |
* for an element, or null if there is no transformation (in |
3711 |
> |
* which case the action is not applied) |
3712 |
|
*/ |
3713 |
|
public <U> void forEachValueSequentially |
3714 |
|
(Fun<? super V, ? extends U> transformer, |
3767 |
|
* null if none. |
3768 |
|
* |
3769 |
|
* @param transformer a function returning the transformation |
3770 |
< |
* for an element, or null of there is no transformation (in |
3771 |
< |
* which case it is not combined). |
3770 |
> |
* for an element, or null if there is no transformation (in |
3771 |
> |
* which case it is not combined) |
3772 |
|
* @param reducer a commutative associative combining function |
3773 |
|
* @return the result of accumulating the given transformation |
3774 |
|
* of all values |
3881 |
|
* of each entry. |
3882 |
|
* |
3883 |
|
* @param transformer a function returning the transformation |
3884 |
< |
* for an element, or null of there is no transformation (in |
3885 |
< |
* which case the action is not applied). |
3884 |
> |
* for an element, or null if there is no transformation (in |
3885 |
> |
* which case the action is not applied) |
3886 |
|
* @param action the action |
3887 |
|
*/ |
3888 |
|
@SuppressWarnings("unchecked") public <U> void forEachEntrySequentially |
3944 |
|
* or null if none. |
3945 |
|
* |
3946 |
|
* @param transformer a function returning the transformation |
3947 |
< |
* for an element, or null of there is no transformation (in |
3948 |
< |
* which case it is not combined). |
3947 |
> |
* for an element, or null if there is no transformation (in |
3948 |
> |
* which case it is not combined) |
3949 |
|
* @param reducer a commutative associative combining function |
3950 |
|
* @return the result of accumulating the given transformation |
3951 |
|
* of all entries |
4056 |
|
* of each (key, value). |
4057 |
|
* |
4058 |
|
* @param transformer a function returning the transformation |
4059 |
< |
* for an element, or null of there is no transformation (in |
4060 |
< |
* which case the action is not applied). |
4059 |
> |
* for an element, or null if there is no transformation (in |
4060 |
> |
* which case the action is not applied) |
4061 |
|
* @param action the action |
4062 |
|
*/ |
4063 |
|
public <U> void forEachInParallel |
4091 |
|
* combine values, or null if none. |
4092 |
|
* |
4093 |
|
* @param transformer a function returning the transformation |
4094 |
< |
* for an element, or null of there is no transformation (in |
4095 |
< |
* which case it is not combined). |
4094 |
> |
* for an element, or null if there is no transformation (in |
4095 |
> |
* which case it is not combined) |
4096 |
|
* @param reducer a commutative associative combining function |
4097 |
|
* @return the result of accumulating the given transformation |
4098 |
|
* of all (key, value) pairs |
4179 |
|
* of each key. |
4180 |
|
* |
4181 |
|
* @param transformer a function returning the transformation |
4182 |
< |
* for an element, or null of there is no transformation (in |
4183 |
< |
* which case the action is not applied). |
4182 |
> |
* for an element, or null if there is no transformation (in |
4183 |
> |
* which case the action is not applied) |
4184 |
|
* @param action the action |
4185 |
|
*/ |
4186 |
|
public <U> void forEachKeyInParallel |
4228 |
|
* null if none. |
4229 |
|
* |
4230 |
|
* @param transformer a function returning the transformation |
4231 |
< |
* for an element, or null of there is no transformation (in |
4232 |
< |
* which case it is not combined). |
4231 |
> |
* for an element, or null if there is no transformation (in |
4232 |
> |
* which case it is not combined) |
4233 |
|
* @param reducer a commutative associative combining function |
4234 |
|
* @return the result of accumulating the given transformation |
4235 |
|
* of all keys |
4316 |
|
* of each value. |
4317 |
|
* |
4318 |
|
* @param transformer a function returning the transformation |
4319 |
< |
* for an element, or null of there is no transformation (in |
4320 |
< |
* which case the action is not applied). |
4319 |
> |
* for an element, or null if there is no transformation (in |
4320 |
> |
* which case the action is not applied) |
4321 |
|
*/ |
4322 |
|
public <U> void forEachValueInParallel |
4323 |
|
(Fun<? super V, ? extends U> transformer, |
4363 |
|
* null if none. |
4364 |
|
* |
4365 |
|
* @param transformer a function returning the transformation |
4366 |
< |
* for an element, or null of there is no transformation (in |
4367 |
< |
* which case it is not combined). |
4366 |
> |
* for an element, or null if there is no transformation (in |
4367 |
> |
* which case it is not combined) |
4368 |
|
* @param reducer a commutative associative combining function |
4369 |
|
* @return the result of accumulating the given transformation |
4370 |
|
* of all values |
4451 |
|
* of each entry. |
4452 |
|
* |
4453 |
|
* @param transformer a function returning the transformation |
4454 |
< |
* for an element, or null of there is no transformation (in |
4455 |
< |
* which case the action is not applied). |
4454 |
> |
* for an element, or null if there is no transformation (in |
4455 |
> |
* which case the action is not applied) |
4456 |
|
* @param action the action |
4457 |
|
*/ |
4458 |
|
public <U> void forEachEntryInParallel |
4499 |
|
* or null if none. |
4500 |
|
* |
4501 |
|
* @param transformer a function returning the transformation |
4502 |
< |
* for an element, or null of there is no transformation (in |
4503 |
< |
* which case it is not combined). |
4502 |
> |
* for an element, or null if there is no transformation (in |
4503 |
> |
* which case it is not combined) |
4504 |
|
* @param reducer a commutative associative combining function |
4505 |
|
* @return the result of accumulating the given transformation |
4506 |
|
* of all entries |
4715 |
|
* A view of a ConcurrentHashMapV8 as a {@link Set} of keys, in |
4716 |
|
* which additions may optionally be enabled by mapping to a |
4717 |
|
* common value. This class cannot be directly instantiated. See |
4718 |
< |
* {@link #keySet}, {@link #keySet(Object)}, {@link #newKeySet()}, |
4718 |
> |
* {@link #keySet()}, {@link #keySet(Object)}, {@link #newKeySet()}, |
4719 |
|
* {@link #newKeySet(int)}. |
4720 |
|
*/ |
4721 |
|
public static class KeySetView<K,V> extends CHMView<K,V> |
4732 |
|
* or {@code null} if additions are not supported. |
4733 |
|
* |
4734 |
|
* @return the default mapped value for additions, or {@code null} |
4735 |
< |
* if not supported. |
4735 |
> |
* if not supported |
4736 |
|
*/ |
4737 |
|
public V getMappedValue() { return value; } |
4738 |
|
|
4784 |
|
/** |
4785 |
|
* A view of a ConcurrentHashMapV8 as a {@link Collection} of |
4786 |
|
* values, in which additions are disabled. This class cannot be |
4787 |
< |
* directly instantiated. See {@link #values}, |
4787 |
> |
* directly instantiated. See {@link #values()}. |
4788 |
|
* |
4789 |
|
* <p>The view's {@code iterator} is a "weakly consistent" iterator |
4790 |
|
* that will never throw {@link ConcurrentModificationException}, |
4834 |
|
/** |
4835 |
|
* A view of a ConcurrentHashMapV8 as a {@link Set} of (key, value) |
4836 |
|
* entries. This class cannot be directly instantiated. See |
4837 |
< |
* {@link #entrySet}. |
4837 |
> |
* {@link #entrySet()}. |
4838 |
|
*/ |
4839 |
|
public static final class EntrySetView<K,V> extends CHMView<K,V> |
4840 |
|
implements Set<Map.Entry<K,V>> { |
4870 |
|
} |
4871 |
|
|
4872 |
|
public final boolean add(Entry<K,V> e) { |
4873 |
< |
K key = e.getKey(); |
4873 |
< |
V value = e.getValue(); |
4874 |
< |
if (key == null || value == null) |
4875 |
< |
throw new NullPointerException(); |
4876 |
< |
return map.internalPut(key, value, false) == null; |
4873 |
> |
return map.internalPut(e.getKey(), e.getValue(), false) == null; |
4874 |
|
} |
4875 |
|
public final boolean addAll(Collection<? extends Entry<K,V>> c) { |
4876 |
|
boolean added = false; |
4967 |
|
* @param map the map |
4968 |
|
* @param transformer a function returning the transformation |
4969 |
|
* for an element, or null if there is no transformation (in |
4970 |
< |
* which case it is not combined). |
4970 |
> |
* which case it is not combined) |
4971 |
|
* @param reducer a commutative associative combining function |
4972 |
|
* @return the task |
4973 |
|
*/ |
5134 |
|
* @param map the map |
5135 |
|
* @param transformer a function returning the transformation |
5136 |
|
* for an element, or null if there is no transformation (in |
5137 |
< |
* which case it is not combined). |
5137 |
> |
* which case it is not combined) |
5138 |
|
* @param reducer a commutative associative combining function |
5139 |
|
* @return the task |
5140 |
|
*/ |
5300 |
|
* @param map the map |
5301 |
|
* @param transformer a function returning the transformation |
5302 |
|
* for an element, or null if there is no transformation (in |
5303 |
< |
* which case it is not combined). |
5303 |
> |
* which case it is not combined) |
5304 |
|
* @param reducer a commutative associative combining function |
5305 |
|
* @return the task |
5306 |
|
*/ |
5466 |
|
* @param map the map |
5467 |
|
* @param transformer a function returning the transformation |
5468 |
|
* for an element, or null if there is no transformation (in |
5469 |
< |
* which case it is not combined). |
5469 |
> |
* which case it is not combined) |
5470 |
|
* @param reducer a commutative associative combining function |
5471 |
|
* @return the task |
5472 |
|
*/ |
6801 |
|
private static final int ASHIFT; |
6802 |
|
|
6803 |
|
static { |
6807 |
– |
int ss; |
6804 |
|
try { |
6805 |
|
U = getUnsafe(); |
6806 |
|
Class<?> k = ConcurrentHashMapV8.class; |
6819 |
|
(ck.getDeclaredField("value")); |
6820 |
|
Class<?> sc = Node[].class; |
6821 |
|
ABASE = U.arrayBaseOffset(sc); |
6822 |
< |
ss = U.arrayIndexScale(sc); |
6823 |
< |
ASHIFT = 31 - Integer.numberOfLeadingZeros(ss); |
6822 |
> |
int scale = U.arrayIndexScale(sc); |
6823 |
> |
if ((scale & (scale - 1)) != 0) |
6824 |
> |
throw new Error("data type scale not a power of two"); |
6825 |
> |
ASHIFT = 31 - Integer.numberOfLeadingZeros(scale); |
6826 |
|
} catch (Exception e) { |
6827 |
|
throw new Error(e); |
6828 |
|
} |
6831 |
– |
if ((ss & (ss-1)) != 0) |
6832 |
– |
throw new Error("data type scale not a power of two"); |
6829 |
|
} |
6830 |
|
|
6831 |
|
/** |