53 |
|
* (STRONG, |
54 |
|
* new Equivalence<Person>() { |
55 |
|
* public boolean equal(Person k, Object x) { |
56 |
< |
* return x instanceOf Person && k.name.equals(((Person)x).name); |
56 |
> |
* return x instanceof Person && k.name.equals(((Person)x).name); |
57 |
|
* } |
58 |
|
* public int hash(Object x) { |
59 |
< |
* return (x instanceOf Person)? ((Person)x).name.hashCode() : 0; |
59 |
> |
* return (x instanceof Person) ? ((Person)x).name.hashCode() : 0; |
60 |
|
* } |
61 |
|
* }, |
62 |
|
* STRONG, EQUALS, 0); |
642 |
|
int index = (hash >>> SEGMENT_SHIFT) & SEGMENT_MASK; |
643 |
|
Segment seg = segs[index]; |
644 |
|
if (seg == null) { |
645 |
< |
synchronized(segs) { |
645 |
> |
synchronized (segs) { |
646 |
|
seg = segs[index]; |
647 |
|
if (seg == null) { |
648 |
|
seg = new Segment(); |
1010 |
|
if (seg != null && seg.getTableForTraversal() != null) |
1011 |
|
sum += seg.count; |
1012 |
|
} |
1013 |
< |
return sum >= Integer.MAX_VALUE? Integer.MAX_VALUE : (int)sum; |
1013 |
> |
return (sum >= Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) sum; |
1014 |
|
} |
1015 |
|
|
1016 |
|
/** |
1158 |
|
* <pre> |
1159 |
|
* map.compute(word, new RemappingFunction<String,Integer>() { |
1160 |
|
* public Integer remap(String k, Integer v) { |
1161 |
< |
* return v == null? 1 : v + 1; |
1161 |
> |
* return (v == null) ? 1 : v + 1; |
1162 |
|
* }}); |
1163 |
|
* </pre> |
1164 |
|
* |
1558 |
|
* for each key-value mapping, followed by a null pair. |
1559 |
|
* The key-value mappings are emitted in no particular order. |
1560 |
|
*/ |
1561 |
< |
private void writeObject(java.io.ObjectOutputStream s) throws IOException { |
1561 |
> |
private void writeObject(java.io.ObjectOutputStream s) throws IOException { |
1562 |
|
s.defaultWriteObject(); |
1563 |
|
for (Map.Entry<K,V> e : entrySet()) { |
1564 |
|
s.writeObject(e.getKey()); |
1573 |
|
* @param s the stream |
1574 |
|
*/ |
1575 |
|
private void readObject(java.io.ObjectInputStream s) |
1576 |
< |
throws IOException, ClassNotFoundException { |
1576 |
> |
throws IOException, ClassNotFoundException { |
1577 |
|
s.defaultReadObject(); |
1578 |
|
this.segments = (Segment[])(new Segment[NSEGMENTS]); |
1579 |
|
for (;;) { |
1975 |
|
} |
1976 |
|
public final Object getValue() { |
1977 |
|
EmbeddedWeakReference vr = valueRef; |
1978 |
< |
return vr == null? null : vr.get(); |
1978 |
> |
return (vr == null) ? null : vr.get(); |
1979 |
|
} |
1980 |
|
public final void setValue(Object value) { |
1981 |
|
if (value == null) |
2043 |
|
} |
2044 |
|
public final Object getValue() { |
2045 |
|
EmbeddedSoftReference vr = valueRef; |
2046 |
< |
return vr == null? null : vr.get(); |
2046 |
> |
return (vr == null) ? null : vr.get(); |
2047 |
|
} |
2048 |
|
public final void setValue(Object value) { |
2049 |
|
if (value == null) |
2101 |
|
final int locator; |
2102 |
|
final CustomConcurrentHashMap cchm; |
2103 |
|
WeakKeyNode(int locator, Object key, CustomConcurrentHashMap cchm) { |
2104 |
< |
super(key); |
2104 |
> |
super(key, getReclamationQueue()); |
2105 |
|
this.locator = locator; |
2106 |
|
this.cchm = cchm; |
2107 |
|
} |
2123 |
|
|
2124 |
|
static final class TerminalWeakKeySelfValueNode |
2125 |
|
extends WeakKeySelfValueNode { |
2126 |
< |
TerminalWeakKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) { |
2126 |
> |
TerminalWeakKeySelfValueNode(int locator, Object key, |
2127 |
> |
CustomConcurrentHashMap cchm) { |
2128 |
|
super(locator, key, cchm); |
2129 |
|
} |
2130 |
|
public final Node getLinkage() { return null; } |
2276 |
|
} |
2277 |
|
public final Object getValue() { |
2278 |
|
EmbeddedWeakReference vr = valueRef; |
2279 |
< |
return vr == null? null : vr.get(); |
2279 |
> |
return (vr == null) ? null : vr.get(); |
2280 |
|
} |
2281 |
|
public final void setValue(Object value) { |
2282 |
|
if (value == null) |
2339 |
|
} |
2340 |
|
public final Object getValue() { |
2341 |
|
EmbeddedSoftReference vr = valueRef; |
2342 |
< |
return vr == null? null : vr.get(); |
2342 |
> |
return (vr == null) ? null : vr.get(); |
2343 |
|
} |
2344 |
|
public final void setValue(Object value) { |
2345 |
|
if (value == null) |
2397 |
|
final int locator; |
2398 |
|
final CustomConcurrentHashMap cchm; |
2399 |
|
SoftKeyNode(int locator, Object key, CustomConcurrentHashMap cchm) { |
2400 |
< |
super(key); |
2400 |
> |
super(key, getReclamationQueue()); |
2401 |
|
this.locator = locator; |
2402 |
|
this.cchm = cchm; |
2403 |
|
} |
2571 |
|
} |
2572 |
|
public final Object getValue() { |
2573 |
|
EmbeddedWeakReference vr = valueRef; |
2574 |
< |
return vr == null? null : vr.get(); |
2574 |
> |
return (vr == null) ? null : vr.get(); |
2575 |
|
} |
2576 |
|
public final void setValue(Object value) { |
2577 |
|
if (value == null) |
2634 |
|
} |
2635 |
|
public final Object getValue() { |
2636 |
|
EmbeddedSoftReference vr = valueRef; |
2637 |
< |
return vr == null? null : vr.get(); |
2637 |
> |
return (vr == null) ? null : vr.get(); |
2638 |
|
} |
2639 |
|
public final void setValue(Object value) { |
2640 |
|
if (value == null) |
2862 |
|
} |
2863 |
|
public final Object getValue() { |
2864 |
|
EmbeddedWeakReference vr = valueRef; |
2865 |
< |
return vr == null? null : vr.get(); |
2865 |
> |
return (vr == null) ? null : vr.get(); |
2866 |
|
} |
2867 |
|
public final void setValue(Object value) { |
2868 |
|
if (value == null) |
2919 |
|
volatile EmbeddedSoftReference valueRef; |
2920 |
|
final CustomConcurrentHashMap cchm; |
2921 |
|
IntKeySoftValueNode(int locator, Object key, Object value, |
2922 |
< |
CustomConcurrentHashMap cchm) { |
2922 |
> |
CustomConcurrentHashMap cchm) { |
2923 |
|
super(locator, key); |
2924 |
|
this.cchm = cchm; |
2925 |
|
if (value != null) |
2930 |
|
} |
2931 |
|
public final Object getValue() { |
2932 |
|
EmbeddedSoftReference vr = valueRef; |
2933 |
< |
return vr == null? null : vr.get(); |
2933 |
> |
return (vr == null) ? null : vr.get(); |
2934 |
|
} |
2935 |
|
public final void setValue(Object value) { |
2936 |
|
if (value == null) |
2985 |
|
|
2986 |
|
// Temporary Unsafe mechanics for preliminary release |
2987 |
|
|
2988 |
< |
static final Unsafe _unsafe; |
2988 |
> |
static final Unsafe UNSAFE; |
2989 |
|
static final long tableBase; |
2990 |
|
static final int tableShift; |
2991 |
|
static final long segmentsBase; |
3016 |
|
|
3017 |
|
static { |
3018 |
|
try { |
3019 |
< |
_unsafe = getUnsafe(); |
3020 |
< |
tableBase = _unsafe.arrayBaseOffset(Node[].class); |
3021 |
< |
int s = _unsafe.arrayIndexScale(Node[].class); |
3019 |
> |
UNSAFE = getUnsafe(); |
3020 |
> |
tableBase = UNSAFE.arrayBaseOffset(Node[].class); |
3021 |
> |
int s = UNSAFE.arrayIndexScale(Node[].class); |
3022 |
|
if ((s & (s-1)) != 0) |
3023 |
|
throw new Error("data type scale not a power of two"); |
3024 |
|
tableShift = 31 - Integer.numberOfLeadingZeros(s); |
3025 |
< |
segmentsBase = _unsafe.arrayBaseOffset(Segment[].class); |
3026 |
< |
s = _unsafe.arrayIndexScale(Segment[].class); |
3025 |
> |
segmentsBase = UNSAFE.arrayBaseOffset(Segment[].class); |
3026 |
> |
s = UNSAFE.arrayIndexScale(Segment[].class); |
3027 |
|
if ((s & (s-1)) != 0) |
3028 |
|
throw new Error("data type scale not a power of two"); |
3029 |
|
segmentsShift = 31 - Integer.numberOfLeadingZeros(s); |
3036 |
|
static final void storeNode(Node[] table, |
3037 |
|
int i, Node r) { |
3038 |
|
long nodeOffset = ((long) i << tableShift) + tableBase; |
3039 |
< |
_unsafe.putOrderedObject(table, nodeOffset, r); |
3039 |
> |
UNSAFE.putOrderedObject(table, nodeOffset, r); |
3040 |
|
} |
3041 |
|
|
3042 |
|
static final void storeSegment(Segment[] segs, |
3043 |
|
int i, Segment s) { |
3044 |
|
long segmentOffset = ((long) i << segmentsShift) + segmentsBase; |
3045 |
< |
_unsafe.putOrderedObject(segs, segmentOffset, s); |
3045 |
> |
UNSAFE.putOrderedObject(segs, segmentOffset, s); |
3046 |
|
} |
3047 |
|
|
3048 |
|
|