简体   繁体   English

内置的java排序算法,用于使用Quicksort的数组/链表

[英]Inbuilt java sorting algorithms for array/linked lists that uses Quicksort

I need to bench mark my quick sort algorithm with an inbuilt java sort. 我需要使用内置的java排序来标记我的快速排序算法。 Since I am using arraylists and linkedlists, I need an inbuilt java sort that would sort with quick sort. 由于我使用的是arraylists和链表,我需要一个内置的java排序,可以快速排序。

I have tried Arrays.sort(), but there doesn't seem to work for array and linked lists as arguments. 我试过Arrays.sort(),但似乎没有数组和链表作为参数。

And also from Why does Collections.sort use Mergesort but Arrays.sort does not? 而且, 为什么Collections.sort使用Mergesort但是Arrays.sort却没有? It is said that the collections.sort() uses merge sort, and that there isn't any inbuilt sort for non primitive types that uses quick sort cause of stability requirements. 据说collections.sort()使用合并排序,并且对于使用快速排序导致稳定性要求的非基元类型没有任何内置排序。

So how might I use an inbuilt java algorithm that uses Quicksort to sort arraylist and linkedlists? 那么我如何使用内置的java算法使用Quicksort对arraylist和链表进行排序呢?

Would it be a way to reverse the test-procedure? 它是一种扭转测试程序的方法吗?
Modify your sorting algorithm to work with an array and use Arrays.sort() to match it. 修改排序算法以使用数组并使用Arrays.sort()来匹配它。
Both classes – ArrayList and LinkedList – are having a toArray() function. 两个类 - ArrayListLinkedList - 都具有toArray()函数。
Arrays.sort() calls java.util.ComparableTimSort.sort() internally. Arrays.sort() java.util.ComparableTimSort.sort()内部调用java.util.ComparableTimSort.sort()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM