本文整理汇总了Java中it.unimi.dsi.fastutil.ints.IntArrays.trim方法的典型用法代码示例。如果您正苦于以下问题:Java IntArrays.trim方法的具体用法?Java IntArrays.trim怎么用?Java IntArrays.trim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.ints.IntArrays
的用法示例。
在下文中一共展示了IntArrays.trim方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTestingSet
import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
public int[] createTestingSet(int numOfSamples) {
numOfSamples = Math.min(numOfSamples, numNodes);
if (verbose) LOGGER.info("Creating test set with "+numOfSamples+" nodes...");
if (numOfSamples >= (numNodes/2)) {
final Random rnd = RandomSingleton.get();
int[] samples = MathArrays.natural(numNodes);
IntArrays.shuffle(samples, rnd);
return IntArrays.trim(samples, numOfSamples);
} else {
IntSet set = new IntOpenHashSet();
while (set.size() < numOfSamples) {
set.add(rnd.nextInt(numNodes));
}
int[] r = set.toIntArray();
return r;
}
}
示例2: getTop
import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
public IntSet getTop(int k) {
if (k > graph.numNodes())
LOGGER.warn("Warning: " + k + " categories were asked, but the graph contains " + graph.numNodes());
LOGGER.info("Computing top-"+k+" categories...");
IntSet okIds = new IntOpenHashSet(IntArrays.trim(positions, k));
LOGGER.info("Top-"+k+" categories computed.");
return okIds;
}
示例3: unwrap
import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
/** Unwraps the elements returned by a lazy iterator into a new array.
*
* <p>If you need the resulting array to contain the
* elements returned by <code>lazyIntIterator</code>, but some more elements set to zero
* would cause no harm, consider using {@link #unwrapLoosely(LazyIntIterator)}, which
* usually avoids a final call to {@link IntArrays#trim(int[], int)}.
*
* @param lazyIntIterator a lazy integer iterator.
* @return an array containing the elements returned by <code>lazyIntIterator</code>.
* @see #unwrapLoosely(LazyIntIterator)
*/
public static int[] unwrap( final LazyIntIterator lazyIntIterator ) {
int array[] = new int[ 16 ];
int j = 0, t;
while( ( t = lazyIntIterator.nextInt() ) != -1 ) {
if ( j == array.length ) array = IntArrays.grow( array, j + 1 );
array[ j++ ] = t;
}
return IntArrays.trim( array, j );
}
示例4: results
import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
/**
* @return at most <i>howMany</i> out-links of node, ordered by their unexpected (most unexpected first)
*/
public int[] results(int node, int howMany) {
return IntArrays.trim(results(node), howMany);
}