当前位置: 首页>>代码示例>>Java>>正文


Java HashCommon.nextPowerOfTwo方法代码示例

本文整理汇总了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;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:12,代码来源:HashIndexSet.java

示例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();
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:14,代码来源:ReorderingBlockingQueue.java

示例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;
}
 
开发者ID:aikar,项目名称:fastutil-lite,代码行数:28,代码来源:Long2ObjectLinkedOpenHashMap.java


注:本文中的it.unimi.dsi.fastutil.HashCommon.nextPowerOfTwo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。