1 |
|
/* |
2 |
< |
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
2 |
> |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
3 |
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
|
* |
5 |
|
* This code is free software; you can redistribute it and/or modify it |
376 |
|
* Returns a power of two size for the given target capacity. |
377 |
|
*/ |
378 |
|
static final int tableSizeFor(int cap) { |
379 |
< |
int n = cap - 1; |
380 |
< |
n |= n >>> 1; |
381 |
< |
n |= n >>> 2; |
382 |
< |
n |= n >>> 4; |
383 |
< |
n |= n >>> 8; |
384 |
< |
n |= n >>> 16; |
379 |
> |
int n = -1 >>> Integer.numberOfLeadingZeros(cap - 1); |
380 |
|
return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1; |
381 |
|
} |
382 |
|
|
1263 |
|
@Override |
1264 |
|
public V merge(K key, V value, |
1265 |
|
BiFunction<? super V, ? super V, ? extends V> remappingFunction) { |
1266 |
< |
if (value == null) |
1272 |
< |
throw new NullPointerException(); |
1273 |
< |
if (remappingFunction == null) |
1266 |
> |
if (value == null || remappingFunction == null) |
1267 |
|
throw new NullPointerException(); |
1268 |
|
int hash = hash(key); |
1269 |
|
Node<K,V>[] tab; Node<K,V> first; int n, i; |
1306 |
|
else |
1307 |
|
removeNode(hash, key, null, false, true); |
1308 |
|
return v; |
1309 |
< |
} |
1317 |
< |
if (value != null) { |
1309 |
> |
} else { |
1310 |
|
if (t != null) |
1311 |
|
t.putTreeVal(this, tab, hash, key, value); |
1312 |
|
else { |
1317 |
|
++modCount; |
1318 |
|
++size; |
1319 |
|
afterNodeInsertion(true); |
1320 |
+ |
return value; |
1321 |
|
} |
1329 |
– |
return value; |
1322 |
|
} |
1323 |
|
|
1324 |
|
@Override |