Java 类it.unimi.dsi.fastutil.ints.AbstractIntComparator 实例源码

项目:reversegeocode    文件:BuildLayeredIndexSliced.java   
/**
 * 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;
}
项目:presto    文件:ArrayIntersectFunction.java   
private static IntComparator IntBlockCompare(Type type, Block block)
{
    return new AbstractIntComparator()
    {
        @Override
        public int compare(int left, int right)
        {
            if (block.isNull(left) && block.isNull(right)) {
                return 0;
            }
            if (block.isNull(left)) {
                return -1;
            }
            if (block.isNull(right)) {
                return 1;
            }
            return type.compareTo(block, left, block, right);
        }
    };
}
项目:llamafur    文件:ArrayUtils.java   
public static IntComparator reverseIndirectComparator(final double[] x) {
    return new AbstractIntComparator(){

        @Override
        public int compare(int k1, int k2) {
            return Double.compare(x[k2], x[k1]);
        }

    };
}
项目:llamafur    文件:ArrayUtils.java   
public static IntComparator indirectComparator(final double[] x) {
    return new AbstractIntComparator(){

        @Override
        public int compare(int k1, int k2) {
            return Double.compare(x[k1], x[k2]);
        }

    };
}
项目:WebGraph    文件:ConnectedComponents.java   
/**
 * 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 ] ];
}
项目:WebGraph    文件:StronglyConnectedComponents.java   
/** 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 ] ];
}
项目:WebGraph    文件:StronglyConnectedComponentsTarjan.java   
/** 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 ] ];
}