本文整理汇总了Java中it.unimi.dsi.fastutil.HashCommon.nextPowerOfTwo方法的典型用法代码示例。如果您正苦于以下问题:Java HashCommon.nextPowerOfTwo方法的具体用法?Java HashCommon.nextPowerOfTwo怎么用?Java HashCommon.nextPowerOfTwo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.HashCommon
的用法示例。
在下文中一共展示了HashCommon.nextPowerOfTwo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: trimToSize
import it.unimi.dsi.fastutil.HashCommon; //导入方法依赖的package包/类
public boolean trimToSize(final int n) {
final int l = HashCommon.nextPowerOfTwo((int) Math.ceil(n / _loadFactor));
if (this.hashIndexSetProperties.n <= l)
return true;
try {
rehash(l);
} catch (OutOfMemoryError cantDoIt) {
return false;
}
return true;
}
示例2: ReorderingBlockingQueue
import it.unimi.dsi.fastutil.HashCommon; //导入方法依赖的package包/类
/** Creates a {@code ReorderingBlockingQueue} with the given fixed
* capacity.
*
* @param capacity the capacity of this queue (will be rounded to the next power of two).
*/
public ReorderingBlockingQueue(final int capacity) {
if (capacity <= 0) throw new IllegalArgumentException();
a = new Object[HashCommon.nextPowerOfTwo(capacity)];
mask = a.length - 1;
lock = new ReentrantLock(false);
nextObjectReady = lock.newCondition();
newSpaceAvailable = lock.newCondition();
}
示例3: trim
import it.unimi.dsi.fastutil.HashCommon; //导入方法依赖的package包/类
/** Rehashes this map if the table is too large.
*
* <P>Let <var>N</var> be the smallest table size that can hold
* <code>max(n,{@link #size()})</code> entries, still satisfying the load factor. If the current
* table size is smaller than or equal to <var>N</var>, this method does
* nothing. Otherwise, it rehashes this map in a table of size
* <var>N</var>.
*
* <P>This method is useful when reusing maps. {@linkplain #clear() Clearing a
* map} leaves the table size untouched. If you are reusing a map
* many times, you can call this method with a typical
* size to avoid keeping around a very large table just
* because of a few large transient maps.
*
* @param n the threshold for the trimming.
* @return true if there was enough memory to trim the map.
* @see #trim()
*/
public boolean trim( final int n ) {
final int l = HashCommon.nextPowerOfTwo( (int)Math.ceil( n / f ) );
if ( l >= n || size > maxFill( l, f ) ) return true;
try {
rehash( l );
}
catch( OutOfMemoryError cantDoIt ) { return false; }
return true;
}