Java 在TimSort方法中调用什么方法?
TimSort是Java 7中默认使用的排序算法 我找到了这个源代码,但我不知道调用哪个方法,因为它们都是私有的。 有人能理解吗?多谢各位Java 在TimSort方法中调用什么方法?,java,sorting,timsort,Java,Sorting,Timsort,TimSort是Java 7中默认使用的排序算法 我找到了这个源代码,但我不知道调用哪个方法,因为它们都是私有的。 有人能理解吗?多谢各位 你什么都不打 它具有包专用于java.util的排序方法。当您调用Arrays.sort()函数或类似函数时,可以让它调用它们 评论清楚地表明了这一点: /* * The next two methods (which are package private and static) constitute * the entire API of this
你什么都不打 它具有包专用于
java.util
的排序方法。当您调用Arrays.sort()函数或类似函数时,可以让它调用它们
评论清楚地表明了这一点:
/*
* The next two methods (which are package private and static) constitute
* the entire API of this class. Each of these methods obeys the contract
* of the public method with the same signature in java.util.Arrays.
*/
static <T> void sort(T[] a, Comparator<? super T> c) {
sort(a, 0, a.length, c);
}
static <T> void sort(T[] a, int lo, int hi, Comparator<? super T> c) {
...
}
你什么都不打
它具有包专用于java.util
的排序方法。当您调用Arrays.sort()函数或类似函数时,可以让它调用它们
评论清楚地表明了这一点:
/*
* The next two methods (which are package private and static) constitute
* the entire API of this class. Each of these methods obeys the contract
* of the public method with the same signature in java.util.Arrays.
*/
static <T> void sort(T[] a, Comparator<? super T> c) {
sort(a, 0, a.length, c);
}
static <T> void sort(T[] a, int lo, int hi, Comparator<? super T> c) {
...
}
该死您知道Java中Tim排序的任何“完整”源代码吗?我想我还不能调用这个方法,因为我们不在Java7中=x谢谢。@Seva您有特殊需要打电话给TimSort吗?还有,有没有什么东西阻止你复制/粘贴它,让一两个方法公开,并改变它所在的包?是的,我想测试一下方法的速度。在这段代码中有一行调用Arrays.Sort,在当前的Java版本中,它只调用调优的快速排序或调优的合并排序。它不会调用TimSort,因为它将在Java 7中实现。那么,有人知道完整的源代码吗?@Seva您可以通过在我列出的两个方法之前添加“public”来修改它,然后将包更改为您想要的任何包。。。然后可以调用TimSort.sort(myArray,myComparator)代码>该死。您知道Java中Tim排序的任何“完整”源代码吗?我想我还不能调用这个方法,因为我们不在Java7中=x谢谢。@Seva您有特殊需要打电话给TimSort吗?还有,有没有什么东西阻止你复制/粘贴它,让一两个方法公开,并改变它所在的包?是的,我想测试一下方法的速度。在这段代码中有一行调用Arrays.Sort,在当前的Java版本中,它只调用调优的快速排序或调优的合并排序。它不会调用TimSort,因为它将在Java 7中实现。那么,有人知道完整的源代码吗?@Seva您可以通过在我列出的两个方法之前添加“public”来修改它,然后将包更改为您想要的任何包。。。然后可以调用TimSort.sort(myArray,myComparator)代码>