1
A
回答
5
你什么也别打。
它有排序方法,包装私人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) {
...
}
通过我的最后意见的时间判断,这花了不到15分钟的事:
- http://pastebin.com/VNyUutiD - SortTest.java
- http://pastebin.com/deGAfWZj - TimSort.java
And th e结果:
C:\Documents and Settings\glowcoder\My Documents>java SortTest
Time for default: 4094ms
Time for timsort: 3813ms
C:\Documents and Settings\glowcoder\My Documents>
相关问题
- 1. Struts调用什么方法?
- 2. 什么是调用方法和调用方法?
- 3. 为什么从基类调用方法调用子方法?
- 4. 什么是隐式方法调用和显式方法调用?
- 5. 什么是从JavaScript中调用WebService方法的最好方法?
- 6. Moq为什么不能在.Select方法中调用此方法?
- 7. 在ruby中调用类方法的更好方法是什么?
- 8. 在Java中使用此方法调用时调用的方法是什么?
- 9. 不用lodash调用方法的另一种方法是什么?
- 10. 为什么可以用另一种方法调用方法?
- 11. 在python sorted()方法中实现的timsort算法
- 12. 用什么方法?
- 13. 回调方法 - 为什么称为回调方法的生命周期方法?
- 14. 调用d.dispose()或s.cancel()方法的正确方法是什么?
- 15. 调用javascript方法的两种方法有什么区别
- 16. 为什么不是put方法调用我的.to_s方法?
- 17. 从C++调用Java方法的最简单方法是什么?
- 18. 为什么调用基类方法代替派生类方法?
- 19. 为什么允许静态方法调用私有方法?
- 20. 为什么不调用paintComponent方法?在printComponent方法要打印
- 21. 什么是从Javascript调用C#方法的最简单方法
- 22. 为什么调用onDestroy()方法?
- 23. 为什么objectAnimator不调用setter方法
- 24. CreateUserWizard的什么方法调用Membership.CreateUser?
- 25. 什么是统计API调用方法?
- 26. 从backstack调用什么方法
- 27. 为什么每个方法被调用?
- 28. 为什么Next()方法调用next?
- 29. 什么时候ConvertBack方法被调用?
- 30. 为什么不运行方法调用?
+1你又找到了我 – MByD 2011-05-02 23:24:11
该死。你知道蒂姆排序在Java中的任何“完整”来源吗?我想我不能调用该方法,因为我们不在Java 7中。= x谢谢。 – Seva 2011-05-02 23:25:03
@Seva你有没有特别需要打电话给TimSort?而且,是否有任何东西阻止你复制/粘贴并制作一个或两个“public”方法并更改它所在的包? – corsiKa 2011-05-02 23:27:02