214 |
|
*/ |
215 |
|
@SuppressWarnings("unchecked") |
216 |
|
static final <K,V> HashEntry<K,V> entryAt(HashEntry<K,V>[] tab, int i) { |
217 |
< |
return tab == null? null : |
217 |
> |
return (tab == null) ? null : |
218 |
|
(HashEntry<K,V>) UNSAFE.getObjectVolatile |
219 |
|
(tab, ((long)i << TSHIFT) + TBASE); |
220 |
|
} |
669 |
|
@SuppressWarnings("unchecked") |
670 |
|
static final <K,V> HashEntry<K,V> entryForHash(Segment<K,V> seg, int h) { |
671 |
|
HashEntry<K,V>[] tab; |
672 |
< |
return seg == null || (tab = seg.table) == null? null : |
672 |
> |
return (seg == null || (tab = seg.table) == null) ? null : |
673 |
|
(HashEntry<K,V>) UNSAFE.getObjectVolatile |
674 |
|
(tab, ((long)(((tab.length - 1) & h)) << TSHIFT) + TBASE); |
675 |
|
} |
997 |
|
* @throws NullPointerException if the specified key or value is null |
998 |
|
*/ |
999 |
|
public V put(K key, V value) { |
1000 |
– |
Segment<K,V> s; |
1000 |
|
if (value == null) |
1001 |
|
throw new NullPointerException(); |
1002 |
|
int hash = hash(key.hashCode()); |
1003 |
|
int j = (hash >>> segmentShift) & segmentMask; |
1004 |
< |
return ((s = segmentAt(segments, j)) == null? ensureSegment(j) : s). |
1005 |
< |
put(key, hash, value, false); |
1004 |
> |
Segment<K,V> s = segmentAt(segments, j); |
1005 |
> |
if (s == null) |
1006 |
> |
s = ensureSegment(j); |
1007 |
> |
return s.put(key, hash, value, false); |
1008 |
|
} |
1009 |
|
|
1010 |
|
/** |
1015 |
|
* @throws NullPointerException if the specified key or value is null |
1016 |
|
*/ |
1017 |
|
public V putIfAbsent(K key, V value) { |
1017 |
– |
Segment<K,V> s; |
1018 |
|
if (value == null) |
1019 |
|
throw new NullPointerException(); |
1020 |
|
int hash = hash(key.hashCode()); |
1021 |
|
int j = (hash >>> segmentShift) & segmentMask; |
1022 |
< |
return ((s = segmentAt(segments, j)) == null? ensureSegment(j) : s). |
1023 |
< |
put(key, hash, value, true); |
1022 |
> |
Segment<K,V> s = segmentAt(segments, j); |
1023 |
> |
if (s == null) |
1024 |
> |
s = ensureSegment(j); |
1025 |
> |
return s.put(key, hash, value, true); |
1026 |
|
} |
1027 |
|
|
1028 |
|
/** |