本文整理汇总了Java中gnu.trove.impl.PrimeFinder.nextPrime方法的典型用法代码示例。如果您正苦于以下问题:Java PrimeFinder.nextPrime方法的具体用法?Java PrimeFinder.nextPrime怎么用?Java PrimeFinder.nextPrime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.impl.PrimeFinder
的用法示例。
在下文中一共展示了PrimeFinder.nextPrime方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postInsertHook
import gnu.trove.impl.PrimeFinder; //导入方法依赖的package包/类
/**
* After an insert, this hook is called to adjust the size/free
* values of the set and to perform rehashing if necessary.
*
* @param usedFreeSlot the slot
*/
protected final void postInsertHook( boolean usedFreeSlot ) {
if ( usedFreeSlot ) {
_free--;
}
// rehash whenever we exhaust the available space in the table
if ( ++_size > _maxSize || _free == 0 ) {
// choose a new capacity suited to the new state of the table
// if we've grown beyond our maximum size, double capacity;
// if we've exhausted the free spots, rehash to the same capacity,
// which will free up any stale removed slots for reuse.
int newCapacity = _size > _maxSize ? PrimeFinder.nextPrime( capacity() << 1 ) : capacity();
rehash( newCapacity );
computeMaxSize( capacity() );
}
}
示例2: postInsertHook
import gnu.trove.impl.PrimeFinder; //导入方法依赖的package包/类
/**
* After an insert, this hook is called to adjust the size/free
* values of the set and to perform rehashing if necessary.
*
* @param usedFreeSlot the slot
*/
protected final void postInsertHook(final boolean usedFreeSlot ) {
if ( usedFreeSlot ) {
_free--;
}
// rehash whenever we exhaust the available space in the table
if ( ++_size > _maxSize || _free == 0 ) {
// choose a new capacity suited to the new state of the table
// if we've grown beyond our maximum size, double capacity;
// if we've exhausted the free spots, rehash to the same capacity,
// which will free up any stale removed slots for reuse.
final int newCapacity = _size > _maxSize ? PrimeFinder.nextPrime( capacity() << 1 ) : capacity();
rehash( newCapacity );
computeMaxSize( capacity() );
}
}
示例3: postInsertHook
import gnu.trove.impl.PrimeFinder; //导入方法依赖的package包/类
/**
* After an insert, this hook is called to adjust the size/free
* values of the set and to perform rehashing if necessary.
*
* @param usedFreeSlot the slot
*/
protected final void postInsertHook( boolean usedFreeSlot ) {
if ( usedFreeSlot ) {
_free--;
}
// rehash whenever we exhaust the available space in the table
if ( ++_size > _maxSize || _free == 0 ) {
// choose a new capacity suited to the new state of the table
// if we've grown beyond our maximum size, double capacity;
// if we've exhausted the free spots, rehash to the same capacity,
// which will free up any stale removed slots for reuse.
int newCapacity = _size > _maxSize ? PrimeFinder.nextPrime( capacity() << 1 ) : capacity();
rehash( newCapacity );
computeMaxSize( capacity() );
}
}
示例4: setUp
import gnu.trove.impl.PrimeFinder; //导入方法依赖的package包/类
/**
* initializes the hashtable to a prime capacity which is at least
* <tt>initialCapacity + 1</tt>.
*
* @param initialCapacity an <code>int</code> value
* @return the actual capacity chosen
*/
protected int setUp( int initialCapacity ) {
int capacity;
capacity = PrimeFinder.nextPrime( initialCapacity );
computeMaxSize( capacity );
computeNextAutoCompactionAmount( initialCapacity );
return capacity;
}
示例5: setUp
import gnu.trove.impl.PrimeFinder; //导入方法依赖的package包/类
/**
* initializes the hashtable to a prime capacity which is at least
* <tt>initialCapacity + 1</tt>.
*
* @param initialCapacity an <code>int</code> value
* @return the actual capacity chosen
*/
int setUp(final int initialCapacity) {
final int capacity;
capacity = PrimeFinder.nextPrime( initialCapacity );
computeMaxSize( capacity );
computeNextAutoCompactionAmount( initialCapacity );
return capacity;
}
示例6: setUp
import gnu.trove.impl.PrimeFinder; //导入方法依赖的package包/类
/**
* initializes the hashtable to a prime capacity which is at least
* <tt>initialCapacity + 1</tt>.
*
* @param initialCapacity an <code>int</code> value
* @return the actual capacity chosen
*/
protected int setUp( int initialCapacity ) {
int capacity;
capacity = PrimeFinder.nextPrime( initialCapacity );
if ( capacity >= PrimeFinder.largestPrime ) {
_loadFactor = 1.0f;
}
computeMaxSize( capacity );
computeNextAutoCompactionAmount( initialCapacity );
return capacity;
}
示例7: setUp
import gnu.trove.impl.PrimeFinder; //导入方法依赖的package包/类
/**
* initializes the hashtable to a prime capacity which is at least
* <tt>initialCapacity + 1</tt>.
*
* @param initialCapacity an <code>int</code> value
* @return the actual capacity chosen
*/
protected int setUp( int initialCapacity ) {
int capacity;
capacity = PrimeFinder.nextPrime( initialCapacity );
if ( capacity >= PrimeFinder.largestPrime ) {
_loadFactor = 1.0f;
}
computeMaxSize( capacity );
computeNextAutoCompactionAmount( initialCapacity );
return capacity;
}
示例8: testPrimeFinder
import gnu.trove.impl.PrimeFinder; //导入方法依赖的package包/类
public void testPrimeFinder() throws Exception {
int r = PrimeFinder.nextPrime(999999);
assertEquals(1070981,r);
}
示例9: testLargeCapacity
import gnu.trove.impl.PrimeFinder; //导入方法依赖的package包/类
public void testLargeCapacity() {
final int twentyFourBitPrime = PrimeFinder.nextPrime( 1 << 24 );
TByteHashSet set = new TByteHashSet( twentyFourBitPrime + 1, 1.0f );
assertTrue( "capacity was not large enough to hold desired elements" , set.capacity() > twentyFourBitPrime );
}
示例10: testMaxValue
import gnu.trove.impl.PrimeFinder; //导入方法依赖的package包/类
public void testMaxValue() throws Exception {
int r = PrimeFinder.nextPrime(Integer.MAX_VALUE);
assertEquals(2004663929, r);
}