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


Java IntArrays.quickSort方法代码示例

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


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

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

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

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

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

示例5: immutableView

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
/** Returns an immutable view of this mutable graph.
 * 
 * <P>The view can be used until this mutable graph is modified. Attempt to use
 * the view after modifying this mutable graph will cause a {@link ConcurrentModificationException}.
 * After modification, a new call to this method will return a new immutable view.
 * 
 * @return an immutable view of this mutable graph.
 */
public ImmutableGraph immutableView() {
	if ( modificationCount != lastModificationCount ) {
		for( int i = n; i-- != 0; ) IntArrays.quickSort( successors[ i ].elements(), 0, successors[ i ].size() );
		immutableView = new ImmutableView( this );
	}
	lastModificationCount = modificationCount;
	return immutableView;
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:17,代码来源:ArrayListMutableGraph.java

示例6: sortBySize

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
/**
 * Renumbers by decreasing size the components of this set.
 * 
 * <p>After a call to this method, both the internal status of this class and the argument array
 * are permuted so that the sizes of connected components are decreasing in the component index.
 * 
 * @param size the components sizes, as returned by {@link #computeSizes()}.
 */
public void sortBySize( final int[] size ) {
	final int[] perm = Util.identity( size.length );
	IntArrays.quickSort( perm, 0, perm.length, new AbstractIntComparator() {
		public int compare( final int x, final int y ) {
			return size[ y ] - size[ x ];
		}
	} );
	final int[] copy = size.clone();
	for ( int i = size.length; i-- != 0; )
		size[ i ] = copy[ perm[ i ] ];
	Util.invertPermutationInPlace( perm );
	for ( int i = component.length; i-- != 0; )
		component[ i ] = perm[ component[ i ] ];
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:23,代码来源:ConnectedComponents.java

示例7: sortBySize

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
/** Renumbers by decreasing size the components of this set.
 *
 * <p>After a call to this method, both the internal status of this class and the argument
 * array are permuted so that the sizes of strongly connected components are decreasing
 * in the component index.
 *
 *  @param size the components sizes, as returned by {@link #computeSizes()}.
 */
public void sortBySize( final int[] size ) {
	final int[] perm = Util.identity( size.length );
	IntArrays.quickSort( perm, 0, perm.length, new AbstractIntComparator() {
		public int compare( final int x, final int y ) {
			return size[ y ] - size[ x ]; 
		}
	});
	final int[] copy = size.clone();
	for ( int i = size.length; i-- != 0; ) size[ i ] = copy[ perm[ i ] ];
	Util.invertPermutationInPlace( perm );
	for( int i = component.length; i-- != 0; ) component[ i ] = perm[ component[ i ] ];
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:21,代码来源:StronglyConnectedComponents.java

示例8: visitDictionary

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
public void visitDictionary(Visitor<Long> visitor, IntDictionaryEncoderVisitorContext context) throws IOException {
    int[] keysArray = null;
    if (sortKeys) {
      keysArray = new int[numElements];
      for (int idx = 0; idx < numElements; idx++) {
        keysArray[idx] = idx;
      }
      IntArrays.quickSort(keysArray, new LongPositionComparator());
    }
    for (int pos = 0; pos < numElements; pos++) {
      context.setOriginalPosition(keysArray == null? pos : keysArray[pos]);
      visitor.visit(context);
    }
}
 
开发者ID:facebookarchive,项目名称:hive-dwrf,代码行数:15,代码来源:IntDictionaryEncoder.java

示例9: successorArray

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
@Override
public int[] successorArray( final int x ) { 
	int[] succ = map.get(x).toIntArray();
	IntArrays.quickSort(succ);
	return succ;
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:7,代码来源:IntMapGraph.java

示例10: CategoryGraphCentralityRanker

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
public CategoryGraphCentralityRanker(ImmutableGraph g, double[] rank) {
	this.graph = g;
	this.rank = rank;
	positions = MathArrays.natural(graph.numNodes());
	IntArrays.quickSort(positions, ArrayUtils.reverseIndirectComparator(rank));
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:7,代码来源:CategoryGraphCentralityRanker.java

示例11: intersect

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
public static Block intersect(Type type, Block leftArray, Block rightArray)
{
    int leftPositionCount = leftArray.getPositionCount();
    int rightPositionCount = rightArray.getPositionCount();

    if (leftPositionCount == 0) {
        return leftArray;
    }
    if (rightPositionCount == 0) {
        return rightArray;
    }

    int[] leftPositions = new int[leftPositionCount];
    int[] rightPositions = new int[rightPositionCount];

    for (int i = 0; i < leftPositionCount; i++) {
        leftPositions[i] = i;
    }
    for (int i = 0; i < rightPositionCount; i++) {
        rightPositions[i] = i;
    }
    IntArrays.quickSort(leftPositions, IntBlockCompare(type, leftArray));
    IntArrays.quickSort(rightPositions, IntBlockCompare(type, rightArray));

    int entrySize;
    if (leftPositionCount < rightPositionCount) {
        entrySize = (int) Math.ceil(leftArray.getSizeInBytes() / (double) leftPositionCount);
    }
    else {
        entrySize = (int) Math.ceil(rightArray.getSizeInBytes() / (double) rightPositionCount);
    }
    BlockBuilder resultBlockBuilder = type.createBlockBuilder(
            new BlockBuilderStatus(),
            Math.min(leftArray.getPositionCount(), rightArray.getPositionCount()),
            entrySize);

    int leftCurrentPosition = 0;
    int rightCurrentPosition = 0;
    int leftBasePosition;
    int rightBasePosition;

    while (leftCurrentPosition < leftPositionCount && rightCurrentPosition < rightPositionCount) {
        leftBasePosition = leftCurrentPosition;
        rightBasePosition = rightCurrentPosition;
        int compareValue = type.compareTo(leftArray, leftPositions[leftCurrentPosition], rightArray, rightPositions[rightCurrentPosition]);
        if (compareValue > 0) {
            rightCurrentPosition++;
        }
        else if (compareValue < 0) {
            leftCurrentPosition++;
        }
        else {
            type.appendTo(leftArray, leftPositions[leftCurrentPosition], resultBlockBuilder);
            leftCurrentPosition++;
            rightCurrentPosition++;
            while (leftCurrentPosition < leftPositionCount && type.equalTo(leftArray, leftPositions[leftBasePosition], leftArray, leftPositions[leftCurrentPosition])) {
                leftCurrentPosition++;
            }
            while (rightCurrentPosition < rightPositionCount && type.equalTo(rightArray, rightPositions[rightBasePosition], rightArray, rightPositions[rightCurrentPosition])) {
                rightCurrentPosition++;
            }
        }
    }

    return resultBlockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:67,代码来源:ArrayIntersectFunction.java

示例12: nodeIterator

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
public NodeIterator nodeIterator() {
	return new NodeIterator() {
		private XorShift1024StarRandom random = new XorShift1024StarRandom( seed );
		
		private Binomial bg = new Binomial( n - ( loops ? 0 : 1 ), p, new RandomEngine() {
			private static final long serialVersionUID = 1L;
			@Override
			public int nextInt() {
				return random.nextInt();
			}
		});

		private int outdegree;
		private int curr = -1;
		private IntOpenHashSet successors = new IntOpenHashSet();
		private int[] successorArray = new int[ 1024 ]; 

		public boolean hasNext() {
			return curr < n - 1;
		}
		
		@Override
		public int nextInt() {
			curr++;
			outdegree = bg.nextInt();
			successors.clear();
			if ( ! loops ) successors.add( curr );
			for( int i = 0; i < outdegree; i++ ) while( ! successors.add( random.nextInt( n ) ) );
			if ( ! loops ) successors.remove( curr );
			successorArray = IntArrays.grow( successorArray, outdegree );
			successors.toIntArray( successorArray );
			IntArrays.quickSort( successorArray, 0, outdegree );
			return curr;
		}
		
		@Override
		public int outdegree() {
			return outdegree;
		}
		
		@Override
		public int[] successorArray() {
			return successorArray;
		}
	};
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:47,代码来源:ErdosRenyiGraph.java

示例13: generate

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
/** Generates an Erd&#x151;s&ndash;R&eacute;nyi graph with the specified seed.
 * 
 * <p>This method exists only for backward compatibility.
 * 
 * @param seed the seed for random generation.
 * @return the generated graph.
 * @deprecated An instance of this class is already an {@link ImmutableSequentialGraph}.
 */
@Deprecated
public ImmutableSequentialGraph generate( final long seed ) {
	LOGGER.debug( "Generating with probability " + p );

	return new ImmutableSequentialGraph() {
		@Override
		public int numNodes() {
			return n;
		}

		@Override
		public ImmutableSequentialGraph copy() {
			return this;
		}

		public NodeIterator nodeIterator() {
			return new NodeIterator() {
				private XorShift1024StarRandom random = new XorShift1024StarRandom( seed );
				
				private Binomial bg = new Binomial( n - ( loops ? 0 : 1 ), p, new RandomEngine() {
					private static final long serialVersionUID = 1L;
					@Override
					public int nextInt() {
						return random.nextInt();
					}
				});

				private int outdegree;
				private int curr = -1;
				private IntOpenHashSet successors = new IntOpenHashSet();
				private int[] successorArray = new int[ 1024 ]; 

				public boolean hasNext() {
					return curr < n - 1;
				}
				
				@Override
				public int nextInt() {
					curr++;
					outdegree = bg.nextInt();
					successors.clear();
					if ( ! loops ) successors.add( curr );
					for( int i = 0; i < outdegree; i++ ) while( ! successors.add( random.nextInt( n ) ) );
					if ( ! loops ) successors.remove( curr );
					successorArray = IntArrays.grow( successorArray, outdegree );
					successors.toIntArray( successorArray );
					IntArrays.quickSort( successorArray, 0, outdegree );
					return curr;
				}
				
				@Override
				public int outdegree() {
					return outdegree;
				}
				
				@Override
				public int[] successorArray() {
					return successorArray;
				}
			};
		}
	};	
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:72,代码来源:ErdosRenyiGraph.java

示例14: nodeIterator

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
@Override
public NodeIterator nodeIterator() {
	
	return new NodeIterator() {
		private final NodeIterator it0 = g0.nodeIterator();
		private int[] succ = IntArrays.EMPTY_ARRAY;
		private IntOpenHashSet successors = new IntOpenHashSet( Hash.DEFAULT_INITIAL_SIZE, Hash.FAST_LOAD_FACTOR );
		private int outdegree = -1; // -1 means that the cache is empty
		
		@Override
		public int nextInt() {
			outdegree = -1;
			return it0.nextInt();
		}

		public boolean hasNext() {
			return it0.hasNext();
		}

		
		@Override
		public int outdegree() {
			if ( outdegree < 0 ) successorArray();
			return outdegree;
		}

		@Override
		public int[] successorArray() {
			if ( outdegree < 0 ) {
				final int d = it0.outdegree();
				final int[] s = it0.successorArray();
				successors.clear();
				for ( int i = 0; i < d; i++ ) { 
					LazyIntIterator s1 = g1.successors( s[ i ] );
					int x;
					while ( ( x = s1.nextInt() ) >= 0 ) successors.add( x );
				}
				outdegree = successors.size();
				succ = IntArrays.ensureCapacity( succ, outdegree, 0 );
				successors.toArray( succ );
				IntArrays.quickSort( succ, 0, outdegree );
			}
			return succ;
		}
	};
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:47,代码来源:Transform.java


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