262 |
|
* because they have negative hash fields and null key and value |
263 |
|
* fields. (These special nodes are either uncommon or transient, |
264 |
|
* so the impact of carrying around some unused fields is |
265 |
< |
* insignficant.) |
265 |
> |
* insignificant.) |
266 |
|
* |
267 |
|
* The table is lazily initialized to a power-of-two size upon the |
268 |
|
* first insertion. Each bin in the table normally contains a |
425 |
|
* |
426 |
|
* TreeBins also require an additional locking mechanism. While |
427 |
|
* list traversal is always possible by readers even during |
428 |
< |
* updates, tree traversal is not, mainly beause of tree-rotations |
428 |
> |
* updates, tree traversal is not, mainly because of tree-rotations |
429 |
|
* that may change the root node and/or its linkages. TreeBins |
430 |
|
* include a simple read-write lock mechanism parasitic on the |
431 |
|
* main bin-synchronization strategy: Structural adjustments |
532 |
|
* Encodings for Node hash fields. See above for explanation. |
533 |
|
*/ |
534 |
|
static final int MOVED = 0x8fffffff; // (-1) hash for forwarding nodes |
535 |
< |
static final int TREEBIN = 0x80000000; // hash for heads of treea |
535 |
> |
static final int TREEBIN = 0x80000000; // hash for roots of trees |
536 |
|
static final int RESERVED = 0x80000001; // hash for transient reservations |
537 |
|
static final int HASH_BITS = 0x7fffffff; // usable bits of normal node hash |
538 |
|
|
552 |
|
* Key-value entry. This class is never exported out as a |
553 |
|
* user-mutable Map.Entry (i.e., one supporting setValue; see |
554 |
|
* MapEntry below), but can be used for read-only traversals used |
555 |
< |
* in bulk tasks. Subclasses of Node with a negativehash field |
555 |
> |
* in bulk tasks. Subclasses of Node with a negative hash field |
556 |
|
* are special, and contain null keys and values (but are never |
557 |
|
* exported). Otherwise, keys and vals are never null. |
558 |
|
*/ |
2542 |
|
} |
2543 |
|
|
2544 |
|
/** |
2545 |
< |
* Returns a list on non-TreeNodes replacing those in given list |
2545 |
> |
* Returns a list on non-TreeNodes replacing those in given list. |
2546 |
|
*/ |
2547 |
|
static <K,V> Node<K,V> untreeify(Node<K,V> b) { |
2548 |
|
Node<K,V> hd = null, tl = null; |
2680 |
|
} |
2681 |
|
|
2682 |
|
/** |
2683 |
< |
* Acquires write lock for tree restructuring |
2683 |
> |
* Acquires write lock for tree restructuring. |
2684 |
|
*/ |
2685 |
|
private final void lockRoot() { |
2686 |
|
if (!U.compareAndSwapInt(this, LOCKSTATE, 0, WRITER)) |
2688 |
|
} |
2689 |
|
|
2690 |
|
/** |
2691 |
< |
* Releases write lock for tree restructuring |
2691 |
> |
* Releases write lock for tree restructuring. |
2692 |
|
*/ |
2693 |
|
private final void unlockRoot() { |
2694 |
|
lockState = 0; |
2695 |
|
} |
2696 |
|
|
2697 |
|
/** |
2698 |
< |
* Possibly blocks awaiting root lock |
2698 |
> |
* Possibly blocks awaiting root lock. |
2699 |
|
*/ |
2700 |
|
private final void contendedLock() { |
2701 |
|
boolean waiting = false; |
2720 |
|
|
2721 |
|
/** |
2722 |
|
* Returns matching node or null if none. Tries to search |
2723 |
< |
* using tree compareisons from root, but continues linear |
2723 |
> |
* using tree comparisons from root, but continues linear |
2724 |
|
* search when lock not available. |
2725 |
|
*/ |
2726 |
|
final Node<K,V> find(int h, Object k) { |
2815 |
|
* that are accessible independently of lock. So instead we |
2816 |
|
* swap the tree linkages. |
2817 |
|
* |
2818 |
< |
* @return true if now too small so should be untreeified. |
2818 |
> |
* @return true if now too small, so should be untreeified |
2819 |
|
*/ |
2820 |
|
final boolean removeTreeNode(TreeNode<K,V> p) { |
2821 |
|
TreeNode<K,V> next = (TreeNode<K,V>)p.next; |
3210 |
|
|
3211 |
|
/** |
3212 |
|
* Base of key, value, and entry Iterators. Adds fields to |
3213 |
< |
* Traverser to support iterator.remove |
3213 |
> |
* Traverser to support iterator.remove. |
3214 |
|
*/ |
3215 |
|
static class BaseIterator<K,V> extends Traverser<K,V> { |
3216 |
|
final ConcurrentHashMap<K,V> map; |
3573 |
|
* of all (key, value) pairs |
3574 |
|
* @since 1.8 |
3575 |
|
*/ |
3576 |
< |
public double reduceToDoubleIn(long parallelismThreshold, |
3577 |
< |
ToDoubleBiFunction<? super K, ? super V> transformer, |
3578 |
< |
double basis, |
3579 |
< |
DoubleBinaryOperator reducer) { |
3576 |
> |
public double reduceToDouble(long parallelismThreshold, |
3577 |
> |
ToDoubleBiFunction<? super K, ? super V> transformer, |
3578 |
> |
double basis, |
3579 |
> |
DoubleBinaryOperator reducer) { |
3580 |
|
if (transformer == null || reducer == null) |
3581 |
|
throw new NullPointerException(); |
3582 |
|
return new MapReduceMappingsToDoubleTask<K,V> |