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