111
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package concurrent.hashmap;
|
||||
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class HashMapTest {
|
||||
static final int MAXIMUM_CAPACITY = 1 << 30;
|
||||
|
||||
@Test
|
||||
public void LinkedBlockingQueueModelTest() throws InterruptedException {
|
||||
System.out.println(tableSizeFor(1000));
|
||||
}
|
||||
|
||||
static final int tableSizeFor(int cap) {
|
||||
int n = cap - 1;
|
||||
n |= n >>> 1;
|
||||
n |= n >>> 2;
|
||||
n |= n >>> 4;
|
||||
n |= n >>> 8;
|
||||
n |= n >>> 16;
|
||||
int t = (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1;
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user