本文整理汇总了Java中gnu.trove.impl.PrimeFinder类的典型用法代码示例。如果您正苦于以下问题:Java PrimeFinder类的具体用法?Java PrimeFinder怎么用?Java PrimeFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrimeFinder类属于gnu.trove.impl包,在下文中一共展示了PrimeFinder类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ensureCapacity
import gnu.trove.impl.PrimeFinder; //导入依赖的package包/类
/**
* Ensure that this hashtable has sufficient capacity to hold
* <tt>desiredCapacity<tt> <b>additional</b> elements without
* requiring a rehash. This is a tuning method you can call
* before doing a large insert.
*
* @param desiredCapacity an <code>int</code> value
*/
public void ensureCapacity( int desiredCapacity ) {
if ( desiredCapacity > ( _maxSize - size() ) ) {
rehash( PrimeFinder.nextPrime(Math.max( _size + 1,
saturatedCast( fastCeil( ( desiredCapacity + _size ) / (double) _loadFactor) + 1 ) ) ) );
if ( capacity() >= PrimeFinder.largestPrime ) {
_loadFactor = 1.0f;
}
computeMaxSize( 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: xxtestMaxHashSetCapacity
import gnu.trove.impl.PrimeFinder; //导入依赖的package包/类
public void xxtestMaxHashSetCapacity() throws Exception {
TIntHashSet full = new TIntHashSet( Integer.MAX_VALUE, 0.5f );
assertEquals( PrimeFinder.nextPrime( Integer.MAX_VALUE ), full.capacity() );
int i;
for (i = 0; full.size() < full.capacity() - 1; i++) {
full.add(i);
}
try {
full.add(++i);
fail( "should have failed to add last key" );
} catch (IllegalStateException ignored) {
}
}
示例9: ensureCapacity
import gnu.trove.impl.PrimeFinder; //导入依赖的package包/类
/**
* Ensure that this hashtable has sufficient capacity to hold
* <tt>desiredCapacity<tt> <b>additional</b> elements without
* requiring a rehash. This is a tuning method you can call
* before doing a large insert.
*
* @param desiredCapacity an <code>int</code> value
*/
public void ensureCapacity( int desiredCapacity ) {
if ( desiredCapacity > ( _maxSize - size() ) ) {
rehash( PrimeFinder.nextPrime(Math.max( _size + 1,
saturatedCast( fastCeil( ( desiredCapacity + _size ) / (double) _loadFactor) + 1 ) ) ) );
if ( capacity() >= PrimeFinder.largestPrime ) {
_loadFactor = 1.0f;
}
computeMaxSize( capacity() );
}
}
示例10: compactToSize
import gnu.trove.impl.PrimeFinder; //导入依赖的package包/类
private void compactToSize(int targetCapacity) {
// need at least one free spot for open addressing
rehash( PrimeFinder.nextPrime( Math.max( targetCapacity + 1,
saturatedCast( fastCeil( targetCapacity / (double) _loadFactor ) + 1 ) ) ) );
computeMaxSize( capacity() );
// If auto-compaction is enabled, re-determine the compaction interval
if ( _autoCompactionFactor != 0 ) {
computeNextAutoCompactionAmount( size() );
}
}
示例11: 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;
}
示例12: testPrimeFinder
import gnu.trove.impl.PrimeFinder; //导入依赖的package包/类
public void testPrimeFinder() throws Exception {
int r = PrimeFinder.nextPrime(999999);
assertEquals(1070981,r);
}
示例13: 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 );
}
示例14: testMaxValue
import gnu.trove.impl.PrimeFinder; //导入依赖的package包/类
public void testMaxValue() throws Exception {
int r = PrimeFinder.nextPrime(Integer.MAX_VALUE);
assertEquals(2004663929, r);
}