1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
package jsr166x; |
865 |
|
} |
866 |
|
if (c == 0) { |
867 |
|
Object v = r.node.value; |
868 |
< |
return (v != null)? (V)v : getUsingFindNode(key); |
868 |
> |
return (v != null) ? (V)v : getUsingFindNode(key); |
869 |
|
} |
870 |
|
bound = rk; |
871 |
|
} |
878 |
|
int c = key.compareTo(nk); |
879 |
|
if (c == 0) { |
880 |
|
Object v = n.value; |
881 |
< |
return (v != null)? (V)v : getUsingFindNode(key); |
881 |
> |
return (v != null) ? (V)v : getUsingFindNode(key); |
882 |
|
} |
883 |
|
if (c < 0) |
884 |
|
return null; |
1246 |
|
findFirst(); // retry |
1247 |
|
clearIndexToFirst(); |
1248 |
|
K key = n.key; |
1249 |
< |
return (keyOnly)? key : new SnapshotEntry<K,V>(key, (V)v); |
1249 |
> |
return keyOnly ? key : new SnapshotEntry<K,V>(key, (V)v); |
1250 |
|
} |
1251 |
|
} |
1252 |
|
|
1306 |
|
Node<K,V> n = b.next; |
1307 |
|
for (;;) { |
1308 |
|
if (n == null) |
1309 |
< |
return (b.isBaseHeader())? null : b; |
1309 |
> |
return b.isBaseHeader() ? null : b; |
1310 |
|
Node<K,V> f = n.next; // inconsistent read |
1311 |
|
if (n != b.next) |
1312 |
|
break; |
1368 |
|
if (head.right == null) |
1369 |
|
tryReduceLevel(); |
1370 |
|
} |
1371 |
< |
return (keyOnly)? key : new SnapshotEntry<K,V>(key, (V)v); |
1371 |
> |
return keyOnly ? key : new SnapshotEntry<K,V>(key, (V)v); |
1372 |
|
} |
1373 |
|
} |
1374 |
|
} |
1432 |
|
Node<K,V> n = b.next; |
1433 |
|
for (;;) { |
1434 |
|
if (n == null) |
1435 |
< |
return ((rel & LT) == 0 || b.isBaseHeader())? null : b; |
1435 |
> |
return ((rel & LT) == 0 || b.isBaseHeader()) ? null : b; |
1436 |
|
Node<K,V> f = n.next; |
1437 |
|
if (n != b.next) // inconsistent read |
1438 |
|
break; |
1448 |
|
(c < 0 && (rel & LT) == 0)) |
1449 |
|
return n; |
1450 |
|
if ( c <= 0 && (rel & LT) != 0) |
1451 |
< |
return (b.isBaseHeader())? null : b; |
1451 |
> |
return b.isBaseHeader() ? null : b; |
1452 |
|
b = n; |
1453 |
|
n = f; |
1454 |
|
} |
1476 |
|
* Return ceiling, or first node if key is <tt>null</tt> |
1477 |
|
*/ |
1478 |
|
Node<K,V> findCeiling(K key) { |
1479 |
< |
return (key == null)? findFirst() : findNear(key, GT|EQ); |
1479 |
> |
return (key == null) ? findFirst() : findNear(key, GT|EQ); |
1480 |
|
} |
1481 |
|
|
1482 |
|
/** |
1483 |
|
* Return lower node, or last node if key is <tt>null</tt> |
1484 |
|
*/ |
1485 |
|
Node<K,V> findLower(K key) { |
1486 |
< |
return (key == null)? findLast() : findNear(key, LT); |
1486 |
> |
return (key == null) ? findLast() : findNear(key, LT); |
1487 |
|
} |
1488 |
|
|
1489 |
|
/** |
1513 |
|
K k = n.key; |
1514 |
|
V v = n.getValidValue(); |
1515 |
|
if (v != null) |
1516 |
< |
return keyOnly? k : new SnapshotEntry<K,V>(k, v); |
1516 |
> |
return keyOnly ? k : new SnapshotEntry<K,V>(k, v); |
1517 |
|
} |
1518 |
|
} |
1519 |
|
|
1534 |
|
return null; |
1535 |
|
V v = doRemove(k, null); |
1536 |
|
if (v != null) |
1537 |
< |
return (keyOnly)? k : new SnapshotEntry<K,V>(k, v); |
1537 |
> |
return keyOnly ? k : new SnapshotEntry<K,V>(k, v); |
1538 |
|
} |
1539 |
|
} |
1540 |
|
|
1555 |
|
return null; |
1556 |
|
V v = doRemove(k, null); |
1557 |
|
if (v != null) |
1558 |
< |
return (keyOnly)? k : new SnapshotEntry<K,V>(k, v); |
1558 |
> |
return keyOnly ? k : new SnapshotEntry<K,V>(k, v); |
1559 |
|
} |
1560 |
|
} |
1561 |
|
|
1883 |
|
if (n.getValidValue() != null) |
1884 |
|
++count; |
1885 |
|
} |
1886 |
< |
return (count >= Integer.MAX_VALUE)? Integer.MAX_VALUE : (int)count; |
1886 |
> |
return (count >= Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int)count; |
1887 |
|
} |
1888 |
|
|
1889 |
|
/** |
2343 |
|
*/ |
2344 |
|
public K ceilingKey(K key) { |
2345 |
|
Node<K,V> n = findNear(key, GT|EQ); |
2346 |
< |
return (n == null)? null : n.key; |
2346 |
> |
return (n == null) ? null : n.key; |
2347 |
|
} |
2348 |
|
|
2349 |
|
/** |
2376 |
|
*/ |
2377 |
|
public K lowerKey(K key) { |
2378 |
|
Node<K,V> n = findNear(key, LT); |
2379 |
< |
return (n == null)? null : n.key; |
2379 |
> |
return (n == null) ? null : n.key; |
2380 |
|
} |
2381 |
|
|
2382 |
|
/** |
2410 |
|
*/ |
2411 |
|
public K floorKey(K key) { |
2412 |
|
Node<K,V> n = findNear(key, LT|EQ); |
2413 |
< |
return (n == null)? null : n.key; |
2413 |
> |
return (n == null) ? null : n.key; |
2414 |
|
} |
2415 |
|
|
2416 |
|
/** |
2443 |
|
*/ |
2444 |
|
public K higherKey(K key) { |
2445 |
|
Node<K,V> n = findNear(key, GT); |
2446 |
< |
return (n == null)? null : n.key; |
2446 |
> |
return (n == null) ? null : n.key; |
2447 |
|
} |
2448 |
|
|
2449 |
|
/** |
3050 |
|
* Creates a new submap. |
3051 |
|
* @param least inclusive least value, or <tt>null</tt> if from start |
3052 |
|
* @param fence exclusive upper bound or <tt>null</tt> if to end |
3053 |
< |
* @throws IllegalArgumentException if least and fence nonnull |
3053 |
> |
* @throws IllegalArgumentException if least and fence non-null |
3054 |
|
* and least greater than fence |
3055 |
|
*/ |
3056 |
|
ConcurrentSkipListSubMap(ConcurrentSkipListMap<K,V> map, |
3128 |
|
|
3129 |
|
public V get(Object key) { |
3130 |
|
K k = (K)key; |
3131 |
< |
return ((!inHalfOpenRange(k)) ? null : m.get(k)); |
3131 |
> |
return (!inHalfOpenRange(k)) ? null : m.get(k); |
3132 |
|
} |
3133 |
|
|
3134 |
|
public V put(K key, V value) { |
3138 |
|
|
3139 |
|
public V remove(Object key) { |
3140 |
|
K k = (K)key; |
3141 |
< |
return (!inHalfOpenRange(k))? null : m.remove(k); |
3141 |
> |
return (!inHalfOpenRange(k)) ? null : m.remove(k); |
3142 |
|
} |
3143 |
|
|
3144 |
|
public int size() { |
3149 |
|
if (n.getValidValue() != null) |
3150 |
|
++count; |
3151 |
|
} |
3152 |
< |
return count >= Integer.MAX_VALUE? Integer.MAX_VALUE : (int)count; |
3152 |
> |
return (count >= Integer.MAX_VALUE) ? |
3153 |
> |
Integer.MAX_VALUE : (int)count; |
3154 |
|
} |
3155 |
|
|
3156 |
|
public boolean isEmpty() { |