Examples of IntIntToInt


Examples of com.almworks.integers.func.IntIntToInt

  /** @return index of a duplicate (not necessarily leftmost) or -1 if none */
  public static int findDuplicate(IntList unsorted) {
    final IntArray sorted = new IntArray(unsorted);
    final IntArray perms = new IntArray(IntProgression.arithmetic(0, sorted.size()));
    IntegersUtils.quicksort(sorted.size(),
        new IntIntToInt() {
          @Override
          public int invoke(int a, int b) {
            return IntCollections.compare(sorted.get(a), sorted.get(b));
          }
        },
View Full Code Here

Examples of com.almworks.integers.func.IntIntToInt

   * @throws IllegalArgumentException in case {@code secondary} is shorter than the {@code primary}
   * */
  public static void sortPairs(final WritableIntList primary, final WritableIntList secondary) throws IllegalArgumentException {
    if (primary.size() > secondary.size()) throw new IllegalArgumentException("secondary is shorter than primary: " +
        primary.size() + " > " + secondary.size());
    IntegersUtils.quicksort(primary.size(), new IntIntToInt() {
          @Override
          public int invoke(int i, int j) {
            int comp = IntCollections.compare(primary.get(i), primary.get(j));
            if (comp == 0) comp = IntCollections.compare(secondary.get(i), secondary.get(j));
            return comp;
View Full Code Here

Examples of com.almworks.integers.func.IntIntToInt

    if (sortAlso != null) {
      for (WritableLongList list : sortAlso) {
        assert list.size() == size();
      }
    }
    IntegersUtils.quicksort(size(), new IntIntToInt() {
      public int invoke(int a, int b) {
        return LongCollections.compare(get(a), get(b));
      }
    }, new IntIntProcedure() {
      public void invoke(int a, int b) {
View Full Code Here

Examples of com.almworks.integers.func.IntIntToInt

  private void restoreIndexMap(int n) {
    // Sort the values remembering the sorting transposition, r
    final IntArray r = new IntArray(IntProgression.arithmetic(0, n));
    IntegersUtils.quicksort(n,
      // order
      new IntIntToInt() {
        @Override
        public int invoke(int i, int j) {
          return LongCollections.compare(myValues.get(i), myValues.get(j));
        }
      },
View Full Code Here

Examples of com.almworks.integers.func.IntIntToInt

  private static void sort(final WritableLongList main, final WritableIntList parallel) {
    assert main.size() == parallel.size();
    // We cannot use PArray.sort(PArray... sortAlso) because types are different
    IntegersUtils.quicksort(main.size(),
      // compare
      new IntIntToInt() { public int invoke(int a, int b) {
        return LongCollections.compare(main.get(a), main.get(b));
      }},
      // swap
      new IntIntProcedure() {
        @Override
View Full Code Here

Examples of com.almworks.integers.func.IntIntToInt

  private void restoreIndexMap(int n) {
    // Sort the values remembering the sorting transposition, r
    final IntArray r = new IntArray(IntProgression.arithmetic(0, n));
    IntegersUtils.quicksort(n,
      // order
      new IntIntToInt() {
        @Override
        public int invoke(int i, int j) {
          return IntCollections.compare(myValues.get(i), myValues.get(j));
        }
      },
View Full Code Here

Examples of com.almworks.integers.func.IntIntToInt

  private static void sort(final WritableIntList main, final WritableIntList parallel) {
    assert main.size() == parallel.size();
    // We cannot use PArray.sort(PArray... sortAlso) because types are different
    IntegersUtils.quicksort(main.size(),
      // compare
      new IntIntToInt() { public int invoke(int a, int b) {
        return IntCollections.compare(main.get(a), main.get(b));
      }},
      // swap
      new IntIntProcedure() {
        @Override
View Full Code Here

Examples of com.almworks.integers.func.IntIntToInt

  private void restoreIndexMap(int n) {
    // Sort the values remembering the sorting transposition, r
    final IntArray r = new IntArray(IntProgression.arithmetic(0, n));
    IntegersUtils.quicksort(n,
      // order
      new IntIntToInt() {
        @Override
        public int invoke(int i, int j) {
          return IntCollections.compare(myValues.get(i), myValues.get(j));
        }
      },
View Full Code Here

Examples of com.almworks.integers.func.IntIntToInt

  private static void sort(final WritableIntList main, final WritableIntList parallel) {
    assert main.size() == parallel.size();
    // We cannot use PArray.sort(PArray... sortAlso) because types are different
    IntegersUtils.quicksort(main.size(),
      // compare
      new IntIntToInt() { public int invoke(int a, int b) {
        return IntCollections.compare(main.get(a), main.get(b));
      }},
      // swap
      new IntIntProcedure() {
        @Override
View Full Code Here

Examples of com.almworks.integers.func.IntIntToInt

  /** @return index of a duplicate (not necessarily leftmost) or -1 if none */
  public static int findDuplicate(LongList unsorted) {
    final LongArray sorted = new LongArray(unsorted);
    final IntArray perms = new IntArray(IntProgression.arithmetic(0, sorted.size()));
    IntegersUtils.quicksort(sorted.size(),
        new IntIntToInt() {
          @Override
          public int invoke(int a, int b) {
            return LongCollections.compare(sorted.get(a), sorted.get(b));
          }
        },
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.