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


Java IntArrays类代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.ints.IntArrays的典型用法代码示例。如果您正苦于以下问题:Java IntArrays类的具体用法?Java IntArrays怎么用?Java IntArrays使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IntArrays类属于it.unimi.dsi.fastutil.ints包,在下文中一共展示了IntArrays类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: HdfsBVGraphNodeIterator

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
private HdfsBVGraphNodeIterator(  final int from, final int upperBound, final InputBitStream ibs, final int[][] window, final int[] outd ) throws IOException {
    if ( from < 0 || from > n ) throw new IllegalArgumentException( "Node index out of range: " + from );
    this.from = from;
    this.ibs = ibs == null ? new InputBitStream(openFile(basename + GRAPH_EXTENSION), 0 ) : ibs;
    if ( window != null ) {
        for ( int i = 0; i < window.length; i++ ) System.arraycopy( window[ i ], 0, this.window[ i ] = IntArrays.grow( this.window[ i ], outd[ i ], 0 ), 0, outd[ i ] );
        System.arraycopy( outd, 0, this.outd, 0, outd.length );
    } else if ( from != 0 ) {
        int pos;
        for( int i = 1; i < Math.min( from + 1, cyclicBufferSize ); i++ ) {
            pos = ( from - i + cyclicBufferSize ) % cyclicBufferSize;
            this.outd[ pos ] = HdfsBVGraph.this.outdegreeInternal( from - i );
            System.arraycopy( successorArray( from - i ), 0, this.window[ pos ] = IntArrays.grow( this.window[ pos ], this.outd[ pos ], 0 ), 0, this.outd[ pos ] );
        }
        this.ibs.position( offsets.getLong( from ) ); // We must fix the bit stream position so that we are *before* the outdegree.
    }
    curr = from - 1;
    this.upperBound = upperBound;
}
 
开发者ID:helgeho,项目名称:HadoopWebGraph,代码行数:20,代码来源:HdfsBVGraph.java

示例2: testBlocking

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
@Test
public void testBlocking() throws InterruptedException {
	for(final int size: new int[] { 10, 100, 128, 256 }) {
		for(final int d: new int[] { 1, 2, 3, 4 }) {
			final ReorderingBlockingQueue<Integer> q = new ReorderingBlockingQueue<>(size / d);
			final int[] perm = Util.identity(size);
			IntArrays.shuffle(perm, new XoRoShiRo128PlusRandom());
			for(int i = perm.length; i-- != 0;) {
				final int t = perm[i];
				new Thread() {
					@Override
					public void run() {
						try {
							q.put(Integer.valueOf(t), t);
						}
						catch (final InterruptedException e) {
							throw new RuntimeException(e.getMessage(), e);
						}
					}
				}.start();
			}
			for(int i = 0; i < perm.length; i++) assertEquals(i, q.take().intValue());
			assertEquals(0, q.size());
		}
	}
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:27,代码来源:ReorderingBlockingQueueTest.java

示例3: prep_uncovered_zeros

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
private List<ME> prep_uncovered_zeros(int[] col_indexes, int[] row_indexes) {
    for(int i = 0; i < col_indexes.length; i++) {
        col_indexes[i] = i;
    }
    for(int i = 0; i < row_indexes.length; i++) {
        row_indexes[i] = i;
    }
    IntArrays.quickSort(row_indexes, new Compare(row_mod, 1));
    IntArrays.quickSort(col_indexes, new Compare(col_mod, -1));
    List<ME> zeros = new ArrayList<>();
    for(ME me : matrix.all()) {
        if(cost(me) == 0) {
            zeros.add(me);
        }
    }
    return zeros;
}
 
开发者ID:jmccrae,项目名称:naisc,代码行数:18,代码来源:MunkRes.java

示例4: learnNPassShuffled

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
public void learnNPassShuffled(int n) throws ReflectiveOperationException, IOException {
	pl.info = classifier.shortStats();
	pl.expectedUpdates = graph.numArcs() * 2 * n;
	pl.start();
	
	for (int pass = 0; pass < n; pass++) {
		LOGGER.info("Starting learning pass #"+(pass+1)+"...");
		int[] nodes = MathArrays.natural(numNodes);
		nodes = IntArrays.shuffle(nodes, rnd);
		
		for (int node : nodes)
			learnNode(node, new IntOpenHashSet(
					graph.successorArray(node), 0, graph.outdegree(node)
					));
		
		save(pass+1);
		
	}

	pl.done();
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:22,代码来源:LatentMatrixEstimator.java

示例5: 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

示例6: indirectSort

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
/**
 * Indirect sort descendingly.
 *
 * @param cnt Count array
 * @return Permutation, largest first
 */
private static int[] indirectSort(long[] cnt) {
  int[] tmp = new int[cnt.length];
  for(int i = 0; i < tmp.length; i++) {
    tmp[i] = i;
  }
  // Indirect sort, descending (no need to sort 0):
  IntArrays.quickSort(tmp, 1, tmp.length, new AbstractIntComparator() {
    private static final long serialVersionUID = 1L;

    @Override
    public int compare(int k1, int k2) {
      return Long.compare(cnt[k2], cnt[k1]);
    }
  });
  return tmp;
}
 
开发者ID:kno10,项目名称:reversegeocode,代码行数:23,代码来源:BuildLayeredIndexSliced.java

示例7: fillCache

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
private void fillCache( int x ) {
	if ( x == cachedNode ) return; 
	MergedIntIterator merge = new MergedIntIterator( x < n0? g0.successors( x ) : LazyIntIterators.EMPTY_ITERATOR, x < n1? g1.successors( x ) : LazyIntIterators.EMPTY_ITERATOR );
	outdegree = 0;
	cache = new int[ INITIAL_ARRAY_SIZE ];
	outdegree += LazyIntIterators.unwrap( merge, cache );
	int upto, t;
	while ( ( t = merge.nextInt() ) != -1 ) {
		upto = cache.length;
		cache = IntArrays.grow( cache, upto + 1 );
		cache[ upto++] = t;
		outdegree++;
		outdegree += LazyIntIterators.unwrap( merge, cache, upto, cache.length - upto );
	}
	cachedNode = x;
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:17,代码来源:UnionImmutableGraph.java

示例8: BVGraphNodeIterator

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
public BVGraphNodeIterator( final InputBitStream ibs, final int from ) throws IOException {
	if ( from < 0 || from > n ) throw new IllegalArgumentException( "Node index out of range: " + from );
	this.from = from;
	this.ibs = ibs;
	if ( from != 0 ) {
		if ( offsetType <= 0 ) throw new IllegalStateException( "You cannot iterate from a chosen node without offsets" );
		
		int pos;
		for( int i = 1; i < Math.min( from + 1, cyclicBufferSize ); i++ ) {
			pos = ( from - i + cyclicBufferSize ) % cyclicBufferSize;
			outd[ pos ] = BVGraph.this.outdegreeInternal( from - i );
			System.arraycopy( BVGraph.this.successorArray( from - i ), 0, window[ pos ] = IntArrays.grow( window[ pos ], outd[ pos ], 0 ), 0, outd[ pos ] );
		}
		ibs.position( offsets.getLong( from ) ); // We must fix the bit stream position so that we are *before* the outdegree.
	}
	curr = from - 1;
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:18,代码来源:BVGraph.java

示例9: distancesFrom

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
private int[] distancesFrom( final ImmutableGraph graph, final int from ) {
	final IntArrayFIFOQueue queue = new IntArrayFIFOQueue();
	final int n = graph.numNodes();
	final int[] dist = new int[ n ];
	IntArrays.fill( dist, Integer.MAX_VALUE ); // Initially, all distances are infinity.

	queue.enqueue( from );
	dist[ from ] = 0;

	LazyIntIterator successors;

	while( ! queue.isEmpty() ) {
		int curr = queue.dequeueInt();
		successors = graph.successors( curr );
		int d = graph.outdegree( curr );
		while( d-- != 0 ) {
			int succ = successors.nextInt();
			if ( dist[ succ ] == Integer.MAX_VALUE ) {
				dist[ succ ] = dist[ curr ] + 1;
				queue.enqueue( succ );
			}
		}
	}
	
	return dist;		
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:27,代码来源:HyperBallTest.java

示例10: BottomSketch

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
public BottomSketch(String str, int nGramSize, int k, boolean doReverseCompliment)
{
	int[] hashes = HashUtils.computeSequenceHashes(str, nGramSize, doReverseCompliment);
	
	k = Math.min(k, hashes.length);
	
	int[] perm = new int[hashes.length];
	for (int iter=0; iter<hashes.length; iter++)
		perm[iter] = iter;

	//sort the array
	IntArrays.radixSortIndirect(perm, hashes, true);
	
	hashPositions = new int[k];
	
	for (int iter=0; iter<k; iter++)
	{
		int index = perm[iter];
		hashPositions[iter] = hashes[index]; 
	}

}
 
开发者ID:marbl,项目名称:MHAP,代码行数:23,代码来源:BottomSketch.java

示例11: visitDictionary

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
private void visitDictionary(Visitor<Text> visitor, VisitorContextImpl context
                    ) throws IOException {
    int[] keysArray = null;
    if (sortKeys) {
      keysArray = new int[numElements];
      for (int idx = 0; idx < numElements; idx++) {
        keysArray[idx] = idx + 1;
      }
      IntArrays.quickSort(keysArray, new TextPositionComparator());
    }

    for (int pos = 0; pos < numElements; pos++) {
      context.setOriginalPosition(keysArray == null? pos + 1: keysArray[pos]);
      visitor.visit(context);
    }
    keysArray = null;
}
 
开发者ID:facebookarchive,项目名称:hive-dwrf,代码行数:18,代码来源:StringDictionaryEncoder.java

示例12: sort

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
/**
 * Given an IntArrayList object, sort it, and return an integer array, containing the sorted elements
 * @param intList: the input list to be sorted
 * @return a sorted integer array
 */
public static int [] sort(IntArrayList intList){
    // Sort the indices and return them
    int [] sorted = new int[intList.size()];
    for (int i = 0; i < intList.size(); i++){
        sorted[i] = intList.getInt(i);
    }
    IntArrays.quickSort(sorted);
    
    return sorted;
}
 
开发者ID:gkiril,项目名称:minie,代码行数:16,代码来源:FastUtil.java

示例13: testNoBlocking

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
@Test
public void testNoBlocking() throws InterruptedException {
	for(final int size: new int[] { 1, 10, 100, 128, 256 }) {
		final ReorderingBlockingQueue<Integer> q = new ReorderingBlockingQueue<>(size);
		final int[] perm = Util.identity(size);
		IntArrays.shuffle(perm, new XoRoShiRo128PlusRandom());
		for(int i = perm.length; i-- != 0;) q.put(Integer.valueOf(perm[i]), perm[i]);
		for(int i = 0; i < perm.length; i++) assertEquals(i, q.take().intValue());
		assertEquals(0, q.size());
	}
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:12,代码来源:ReorderingBlockingQueueTest.java

示例14: sortOn

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
/**
 * Returns a copy of this table sorted using the given comparator
 */
public Table sortOn(IntComparator rowComparator) {
    Table newTable = emptyCopy(rowCount());

    int[] newRows = rows();
    IntArrays.parallelQuickSort(newRows, rowComparator);

    Rows.copyRowsToTable(IntArrayList.wrap(newRows), this, newTable);
    return newTable;
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:13,代码来源:Table.java

示例15: HittingDistanceMinimizer

import it.unimi.dsi.fastutil.ints.IntArrays; //导入依赖的package包/类
@CommandLine(argNames={"graph", "milestones"})
public HittingDistanceMinimizer(ImmutableGraph graph, IntSet milestones) {
	this.graph = Transform.transpose(graph);
	this.milestones = milestones;
	minMilestoneDistance = new int[graph.numNodes()];
	IntArrays.fill(minMilestoneDistance, Integer.MAX_VALUE);
	closestMilestone = new int[graph.numNodes()];
	IntArrays.fill(closestMilestone, -1);
	milestoneQueue = new IntArrayPriorityQueue(milestones.toIntArray());
	runningVisitors = new ObjectOpenHashSet<Visitor>();
	pl  = new ProgressLogger(LOGGER, "milestones");
	pl.expectedUpdates = milestones.size();
	
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:15,代码来源:HittingDistanceMinimizer.java


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