105 |
|
*/ |
106 |
|
public static interface MappingFunction<K, V> { |
107 |
|
/** |
108 |
< |
* Returns a value for the given key, or null if there is no mapping |
108 |
> |
* Returns a value for the given key, or null if there is no mapping. |
109 |
|
* |
110 |
|
* @param key the (non-null) key |
111 |
|
* @return a value for the key, or null if none |
145 |
|
* framework. As illustrated here, Spliterators are well suited to |
146 |
|
* designs in which a task repeatedly splits off half its work |
147 |
|
* into forked subtasks until small enough to process directly, |
148 |
< |
* and then joins these subtasks. Variants of this style can be |
149 |
< |
* also be used in completion-based designs. |
148 |
> |
* and then joins these subtasks. Variants of this style can also |
149 |
> |
* be used in completion-based designs. |
150 |
|
* |
151 |
|
* <pre> |
152 |
|
* {@code ConcurrentHashMapV8<String, Long> m = ... |
192 |
|
* @return a Spliterator covering approximately half of the |
193 |
|
* elements |
194 |
|
* @throws IllegalStateException if this Spliterator has |
195 |
< |
* already commenced traversing elements. |
195 |
> |
* already commenced traversing elements |
196 |
|
*/ |
197 |
|
Spliterator<T> split(); |
198 |
– |
|
199 |
– |
/** |
200 |
– |
* Returns a Spliterator producing the same elements as this |
201 |
– |
* Spliterator. This method may be used for example to create |
202 |
– |
* a second Spliterator before a traversal, in order to later |
203 |
– |
* perform a second traversal. |
204 |
– |
* |
205 |
– |
* @return a Spliterator covering the same range as this Spliterator. |
206 |
– |
* @throws IllegalStateException if this Spliterator has |
207 |
– |
* already commenced traversing elements. |
208 |
– |
*/ |
209 |
– |
Spliterator<T> clone(); |
198 |
|
} |
199 |
|
|
200 |
|
/* |
747 |
|
if (c != (pc = pk.getClass()) || |
748 |
|
!(k instanceof Comparable) || |
749 |
|
(dir = ((Comparable)k).compareTo((Comparable)pk)) == 0) { |
750 |
< |
dir = (c == pc)? 0 : c.getName().compareTo(pc.getName()); |
750 |
> |
dir = (c == pc) ? 0 : c.getName().compareTo(pc.getName()); |
751 |
|
TreeNode r = null, s = null, pl, pr; |
752 |
|
if (dir >= 0) { |
753 |
|
if ((pl = p.left) != null && h <= pl.hash) |
794 |
|
} |
795 |
|
|
796 |
|
/** |
797 |
< |
* Find or add a node |
797 |
> |
* Finds or adds a node. |
798 |
|
* @return null if added |
799 |
|
*/ |
800 |
|
@SuppressWarnings("unchecked") // suppress Comparable cast warning |
811 |
|
if (c != (pc = pk.getClass()) || |
812 |
|
!(k instanceof Comparable) || |
813 |
|
(dir = ((Comparable)k).compareTo((Comparable)pk)) == 0) { |
814 |
< |
dir = (c == pc)? 0 : c.getName().compareTo(pc.getName()); |
814 |
> |
dir = (c == pc) ? 0 : c.getName().compareTo(pc.getName()); |
815 |
|
TreeNode r = null, s = null, pl, pr; |
816 |
|
if (dir >= 0) { |
817 |
|
if ((pl = p.left) != null && h <= pl.hash) |
1005 |
|
sib = (xp = x.parent) == null ? null : xp.right; |
1006 |
|
} |
1007 |
|
if (sib != null) { |
1008 |
< |
sib.red = (xp == null)? false : xp.red; |
1008 |
> |
sib.red = (xp == null) ? false : xp.red; |
1009 |
|
if ((sr = sib.right) != null) |
1010 |
|
sr.red = false; |
1011 |
|
} |
1043 |
|
sib = (xp = x.parent) == null ? null : xp.left; |
1044 |
|
} |
1045 |
|
if (sib != null) { |
1046 |
< |
sib.red = (xp == null)? false : xp.red; |
1046 |
> |
sib.red = (xp == null) ? false : xp.red; |
1047 |
|
if ((sl = sib.left) != null) |
1048 |
|
sl.red = false; |
1049 |
|
} |
2000 |
|
} |
2001 |
|
|
2002 |
|
/** |
2003 |
< |
* Split a normal bin with list headed by e into lo and hi parts; |
2004 |
< |
* install in given table |
2003 |
> |
* Splits a normal bin with list headed by e into lo and hi parts; |
2004 |
> |
* installs in given table. |
2005 |
|
*/ |
2006 |
|
private static void splitBin(Node[] nextTab, int i, Node e) { |
2007 |
|
int bit = nextTab.length >>> 1; // bit to split on |
2031 |
|
} |
2032 |
|
|
2033 |
|
/** |
2034 |
< |
* Split a tree bin into lo and hi parts; install in given table |
2034 |
> |
* Splits a tree bin into lo and hi parts; installs in given table. |
2035 |
|
*/ |
2036 |
|
private static void splitTreeBin(Node[] nextTab, int i, TreeBin t) { |
2037 |
|
int bit = nextTab.length >>> 1; |
2187 |
|
baseLimit = baseSize = (tab == null) ? 0 : tab.length; |
2188 |
|
} |
2189 |
|
|
2190 |
< |
/** Creates iterator for clone() and split() methods */ |
2190 |
> |
/** Creates iterator for clone() and split() methods. */ |
2191 |
|
InternalIterator(InternalIterator<K,V> it, boolean split) { |
2192 |
|
this.map = it.map; |
2193 |
|
this.tab = it.tab; |
2199 |
|
} |
2200 |
|
|
2201 |
|
/** |
2202 |
< |
* Advances next; returns nextVal or null if terminated |
2202 |
> |
* Advances next; returns nextVal or null if terminated. |
2203 |
|
* See above for explanation. |
2204 |
|
*/ |
2205 |
|
final Object advance() { |
2249 |
|
/* ---------------- Public operations -------------- */ |
2250 |
|
|
2251 |
|
/** |
2252 |
< |
* Creates a new, empty map with the default initial table size (16), |
2252 |
> |
* Creates a new, empty map with the default initial table size (16). |
2253 |
|
*/ |
2254 |
|
public ConcurrentHashMapV8() { |
2255 |
|
this.counter = new LongAdder(); |