All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jbox2d.common.FastSort Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
package org.jbox2d.common;

// import com.google.gwt.core.client.JavaScriptObject;

import java.util.Arrays;
import java.util.Comparator;

public class FastSort {
  public static  void unstableSort(T[] array, Comparator comparator) {
    // if (false/*GWT.isProdMode()*/) {
    //   unstableSort(array, 0, array.length, getNativeComparator(comparator));
    // } else {
      Arrays.sort(array, comparator);
    // }
  }

  public static  void unstableSort(T[] array, int fromIndex, int toIndex, Comparator comparator) {
    // if (false/*GWT.isProdMode()*/) {
    //   unstableSort(array, fromIndex, toIndex, getNativeComparator(comparator));
    // } else {
      Arrays.sort(array, fromIndex, toIndex, comparator);
    // }
  }

  // private static native JavaScriptObject getNativeComparator(Comparator comparator) /*-{
  //   return [email protected]::compare(Ljava/lang/Object;Ljava/lang/Object;);
  // }-*/;

  // private static native  void unstableSort(T[] array, int fromIndex, int toIndex, JavaScriptObject comparator) /*-{
  //   var subArray = array.slice(fromIndex, toIndex);
  //   subArray.sort(comparator);
  //   var n = toIndex - fromIndex;
  //   Array.prototype.splice.apply(array, [ fromIndex, n ].concat(subArray
  //       .slice(0, n)));
  // }-*/;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy