@Test public void testNextTwinPrime() { assertEquals(5, RandomUtils.nextTwinPrime(-1)); assertEquals(5, RandomUtils.nextTwinPrime(1)); assertEquals(5, RandomUtils.nextTwinPrime(2)); assertEquals(5, RandomUtils.nextTwinPrime(3)); assertEquals(7, RandomUtils.nextTwinPrime(4)); assertEquals(7, RandomUtils.nextTwinPrime(5)); assertEquals(13, RandomUtils.nextTwinPrime(6)); assertEquals(RandomUtils.MAX_INT_SMALLER_TWIN_PRIME + 2, RandomUtils.nextTwinPrime(RandomUtils.MAX_INT_SMALLER_TWIN_PRIME)); try { RandomUtils.nextTwinPrime(RandomUtils.MAX_INT_SMALLER_TWIN_PRIME + 1); fail(); } catch (IllegalArgumentException iae) { // good } }
public FastIDSet(int size, float loadFactor) { Preconditions.checkArgument(size >= 0, "size must be at least 0"); Preconditions.checkArgument(loadFactor >= 1.0f, "loadFactor must be at least 1.0"); this.loadFactor = loadFactor; int max = (int) (RandomUtils.MAX_INT_SMALLER_TWIN_PRIME / loadFactor); Preconditions.checkArgument(size < max, "size must be less than %d", max); int hashSize = RandomUtils.nextTwinPrime((int) (loadFactor * size)); keys = new long[hashSize]; Arrays.fill(keys, NULL); }
public FastIDSet(int size, float loadFactor) { Preconditions.checkArgument(size >= 0, "size must be at least 0"); Preconditions.checkArgument(loadFactor >= 1.0f, "loadFactor must be at least 1.0"); this.loadFactor = loadFactor; int max = (int) (RandomUtils.MAX_INT_SMALLER_TWIN_PRIME / loadFactor); Preconditions.checkArgument(size < max, "size must be less than %d", max); int hashSize = RandomUtils.nextTwinPrime((int) (loadFactor * size)); keys = new long[hashSize]; Arrays.fill(keys, NULL); }
public FastIDSet(int size, float loadFactor) { Preconditions.checkArgument(size >= 0, "size must be at least 0"); Preconditions.checkArgument(loadFactor >= 1.0f, "loadFactor must be at least 1.0"); this.loadFactor = loadFactor; int max = (int) (RandomUtils.MAX_INT_SMALLER_TWIN_PRIME / loadFactor); Preconditions.checkArgument(size < max, "size must be less than %d", max); int hashSize = RandomUtils.nextTwinPrime((int) (loadFactor * size)); keys = new long[hashSize]; Arrays.fill(keys, NULL); }
public FastIDSet(final int size, final float loadFactor) { Preconditions.checkArgument(size >= 0, "size must be at least 0"); Preconditions.checkArgument(loadFactor >= 1.0f, "loadFactor must be at least 1.0"); this.loadFactor = loadFactor; final int max = (int) (RandomUtils.MAX_INT_SMALLER_TWIN_PRIME / loadFactor); Preconditions.checkArgument(size < max, "size must be less than %d", max); final int hashSize = RandomUtils .nextTwinPrime((int) (loadFactor * size)); keys = new long[hashSize]; Arrays.fill(keys, NULL); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
private void growAndRehash() { if (keys.length * loadFactor >= RandomUtils.MAX_INT_SMALLER_TWIN_PRIME) { throw new IllegalStateException("Can't grow any more"); } rehash(RandomUtils.nextTwinPrime((int) (loadFactor * keys.length))); }
public void rehash() { rehash(RandomUtils.nextTwinPrime((int) (loadFactor * numEntries))); }
public void rehash() { rehash(RandomUtils.nextTwinPrime((int) (loadFactor * numEntries))); }
public void rehash() { rehash(RandomUtils.nextTwinPrime((int) (loadFactor * numEntries))); }