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


Java IntArrays.trim方法代码示例

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

示例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;
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:10,代码来源:CategoryGraphCentralityRanker.java

示例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 );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:23,代码来源:LazyIntIterators.java

示例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);
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:7,代码来源:UnexpectednessScorer.java


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