it.unimi.dsi.fastutil.Arrays类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(263)

本文整理了Java中it.unimi.dsi.fastutil.Arrays类的一些代码示例,展示了Arrays类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Arrays类的具体详情如下:
包路径:it.unimi.dsi.fastutil.Arrays
类名称:Arrays

Arrays介绍

[英]A class providing static methods and objects that do useful things with arrays.

In addition to commodity methods, this class contains Swapper-based implementations of #quickSort(int,int,IntComparator,Swapper) and of a stable, in-place #mergeSort(int,int,IntComparator,Swapper). These generic sorting methods can be used to sort any kind of list, but they find their natural usage, for instance, in sorting arrays in parallel.
[中]提供静态方法和对象的类,这些方法和对象对数组执行有用的操作。
除了商品方法外,此类还包含基于交换程序的#quickSort(int,int,IntComparator,Swapper)和稳定的就地#mergeSort(int,int,IntComparator,Swapper)实现。这些通用排序方法可以用于对任何类型的列表进行排序,但它们可以找到它们的自然用法,例如,在并行排序数组中。

代码示例

代码示例来源:origin: prestodb/presto

private static void sort(final double[] values, final double[] weights, int nextIndex)
{
  // sort x and y value arrays based on the x values
  Arrays.quickSort(0, nextIndex, new AbstractIntComparator()
  {
    @Override
    public int compare(int a, int b)
    {
      return Doubles.compare(values[a], values[b]);
    }
  }, new Swapper()
  {
    @Override
    public void swap(int a, int b)
    {
      double temp = values[a];
      values[a] = values[b];
      values[b] = temp;
      temp = weights[a];
      weights[a] = weights[b];
      weights[b] = temp;
    }
  });
}

代码示例来源:origin: apache/geode

/**
 * Removes elements of this type-specific list using optimized system calls.
 *
 * @param from the start index (inclusive).
 * @param to the end index (exclusive).
 */
@Override
public void removeElements(final int from, final int to) {
 it.unimi.dsi.fastutil.Arrays.ensureFromTo(size, from, to);
 System.arraycopy(a, to, a, from, size - to);
 size -= (to - from);
 int i = to - from;
 while (i-- != 0)
  a[size + i] = null;
}

代码示例来源:origin: it.unimi.dsi/fastutil

if (len > QUICKSORT_MEDIAN_OF_9) { // Big arrays, pseudomedian of 9
  int s = len / 8;
  l = med3(l, l + s, l + 2 * s, comp);
  m = med3(m - s, m, m + s, comp);
  n = med3(n - 2 * s, n - s, n, comp);
m = med3(l, m, n, comp); // Mid-size, med of 3
swap(swapper, from, b - s, s);
s = Math.min(d - c, to - d - 1);
swap(swapper, b, to - s, s);
if ((s = b - a) > 1) quickSort(from, from + s, comp, swapper);
if ((s = d - c) > 1) quickSort(to - s, to, comp, swapper);

代码示例来源:origin: AliView/AliView

if ( len > MEDIUM ) { // Big arrays, pseudomedian of 9
    int s = len / 8;
    l = med3( l, l + s, l + 2 * s, comp );
    m = med3( m - s, m, m + s, comp );
    n = med3( n - 2 * s, n - s, n, comp );
  m = med3( l, m, n, comp ); // Mid-size, med of 3
int n = to;
s = Math.min( a - from, b - a );
vecSwap( swapper, from, b - s, s );
s = Math.min( d - c, n - d - 1 );
vecSwap( swapper, b, n - s, s );
if ( ( s = b - a ) > 1 ) quickSort( from, from + s, comp, swapper );
if ( ( s = d - c ) > 1 ) quickSort( n - s, n, comp, swapper );

代码示例来源:origin: it.unimi.dsi/fastutil

final int len = to - from;
if (len < PARALLEL_QUICKSORT_NO_FORK) {
  quickSort(from, to, comp, swapper);
  return;
swap(swapper, from, b - s, s);
s = Math.min(d - c, to - d - 1);
swap(swapper, b, to - s, s);

代码示例来源:origin: it.unimi.dsi/fastutil

secondCut = lowerBound(mid, to, firstCut, comp);
  firstCut = upperBound(from, mid, secondCut, comp);
inPlaceMerge(from, firstCut, mid, comp, swapper);
inPlaceMerge(mid, secondCut, to, comp, swapper);

代码示例来源:origin: AliView/AliView

/** Ensures that a range given by an offset and a length fits an array.
  *
  * <P>This method may be used whenever an array range check is needed.
  *
  * @param a an array.
  * @param offset a start index.
  * @param length a length (the number of elements in the range).
  * @throws IllegalArgumentException if <code>length</code> is negative.
  * @throws ArrayIndexOutOfBoundsException if <code>offset</code> is negative or <code>offset</code>+<code>length</code> is greater than the array length.
  */
public static void ensureOffsetLength( final boolean[] a, final int offset, final int length ) {
Arrays.ensureOffsetLength( a.length, offset, length );
}
private static final int SMALL = 7;

代码示例来源:origin: it.unimi.dsi/fastutil

mergeSort(from, mid, c, swapper);
mergeSort(mid, to, c, swapper);
inPlaceMerge(from, mid, to, c, swapper);

代码示例来源:origin: AliView/AliView

secondCut = lowerBound( mid, to, firstCut, comp );
  firstCut = upperBound( from, mid, secondCut, comp );
inPlaceMerge( from, firstCut, mid, comp, swapper );
inPlaceMerge( mid, secondCut, to, comp, swapper );

代码示例来源:origin: it.unimi.dsi/fastutil

/**
 * Ensures that a range given by an offset and a length fits an array.
 *
 * <p>
 * This method may be used whenever an array range check is needed.
 *
 * @param a
 *            an array.
 * @param offset
 *            a start index.
 * @param length
 *            a length (the number of elements in the range).
 * @throws IllegalArgumentException
 *             if {@code length} is negative.
 * @throws ArrayIndexOutOfBoundsException
 *             if {@code offset} is negative or {@code offset}+{@code length} is
 *             greater than the array length.
 */
public static void ensureOffsetLength(final byte[] a, final int offset, final int length) {
  Arrays.ensureOffsetLength(a.length, offset, length);
}
/**

代码示例来源:origin: AliView/AliView

mergeSort( from, mid, c, swapper );
mergeSort( mid, to, c, swapper );
inPlaceMerge( from, mid, to, c, swapper );

代码示例来源:origin: apache/incubator-pinot

Arrays.quickSort(0, _numDocs, comparator, swapper);

代码示例来源:origin: AliView/AliView

/** Ensures that a range given by its first (inclusive) and last (exclusive) elements fits an array.
  *
  * <P>This method may be used whenever an array range check is needed.
  *
  * @param a an array.
  * @param from a start index (inclusive).
  * @param to an end index (inclusive).
  * @throws IllegalArgumentException if <code>from</code> is greater than <code>to</code>.
  * @throws ArrayIndexOutOfBoundsException if <code>from</code> or <code>to</code> are greater than the array length or negative.
  */
public static void ensureFromTo( final boolean[] a, final int from, final int to ) {
Arrays.ensureFromTo( a.length, from, to );
}
/** Ensures that a range given by an offset and a length fits an array.

代码示例来源:origin: it.unimi.dsi/fastutil

/**
 * Ensures that a range given by an offset and a length fits an array.
 *
 * <p>
 * This method may be used whenever an array range check is needed.
 *
 * @param a
 *            an array.
 * @param offset
 *            a start index.
 * @param length
 *            a length (the number of elements in the range).
 * @throws IllegalArgumentException
 *             if {@code length} is negative.
 * @throws ArrayIndexOutOfBoundsException
 *             if {@code offset} is negative or {@code offset}+{@code length} is
 *             greater than the array length.
 */
public static void ensureOffsetLength(final short[] a, final int offset, final int length) {
  Arrays.ensureOffsetLength(a.length, offset, length);
}
/**

代码示例来源:origin: apache/incubator-pinot

sortedDocIds[i] = startDocId + i;
it.unimi.dsi.fastutil.Arrays.quickSort(0, numDocs, new IntComparator() {
 @Override
 public int compare(int i1, int i2) {

代码示例来源:origin: it.unimi.dsi/fastutil

/**
 * Ensures that a range given by its first (inclusive) and last (exclusive)
 * elements fits an array.
 *
 * <p>
 * This method may be used whenever an array range check is needed.
 *
 * @param a
 *            an array.
 * @param from
 *            a start index (inclusive).
 * @param to
 *            an end index (exclusive).
 * @throws IllegalArgumentException
 *             if {@code from} is greater than {@code to}.
 * @throws ArrayIndexOutOfBoundsException
 *             if {@code from} or {@code to} are greater than the array length
 *             or negative.
 */
public static void ensureFromTo(final double[] a, final int from, final int to) {
  Arrays.ensureFromTo(a.length, from, to);
}
/**

代码示例来源:origin: it.unimi.dsi/fastutil

/**
 * Ensures that a range given by an offset and a length fits an array.
 *
 * <p>
 * This method may be used whenever an array range check is needed.
 *
 * @param a
 *            an array.
 * @param offset
 *            a start index.
 * @param length
 *            a length (the number of elements in the range).
 * @throws IllegalArgumentException
 *             if {@code length} is negative.
 * @throws ArrayIndexOutOfBoundsException
 *             if {@code offset} is negative or {@code offset}+{@code length} is
 *             greater than the array length.
 */
public static void ensureOffsetLength(final boolean[] a, final int offset, final int length) {
  Arrays.ensureOffsetLength(a.length, offset, length);
}
/**

代码示例来源:origin: apache/incubator-pinot

sortedDocIds[j] = temp;
};
Arrays.quickSort(0, numDocs, comparator, swapper);

代码示例来源:origin: it.unimi.dsi/fastutil

/**
 * Ensures that a range given by its first (inclusive) and last (exclusive)
 * elements fits an array.
 *
 * <p>
 * This method may be used whenever an array range check is needed.
 *
 * @param a
 *            an array.
 * @param from
 *            a start index (inclusive).
 * @param to
 *            an end index (exclusive).
 * @throws IllegalArgumentException
 *             if {@code from} is greater than {@code to}.
 * @throws ArrayIndexOutOfBoundsException
 *             if {@code from} or {@code to} are greater than the array length
 *             or negative.
 */
public static void ensureFromTo(final byte[] a, final int from, final int to) {
  Arrays.ensureFromTo(a.length, from, to);
}
/**

代码示例来源:origin: it.unimi.dsi/fastutil

/**
 * Ensures that a range given by an offset and a length fits an array.
 *
 * <p>
 * This method may be used whenever an array range check is needed.
 *
 * @param a
 *            an array.
 * @param offset
 *            a start index.
 * @param length
 *            a length (the number of elements in the range).
 * @throws IllegalArgumentException
 *             if {@code length} is negative.
 * @throws ArrayIndexOutOfBoundsException
 *             if {@code offset} is negative or {@code offset}+{@code length} is
 *             greater than the array length.
 */
public static <K> void ensureOffsetLength(final K[] a, final int offset, final int length) {
  Arrays.ensureOffsetLength(a.length, offset, length);
}
/**

相关文章