QuickSort

com.phasmidsoftware.sort.QuickSort
object QuickSort

In-place quicksort implementation. It is not stable, but does not allocate extra space (other than stack). Like MergeSort, it uses InsertionSort for sorting very small arrays.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
QuickSort.type

Members list

Value members

Concrete methods

final def limit: Int
final def partition[A : Ordering](data: Array[A], from: Int, to: Int, pivot: Int): Int

Method to partition a sub-array into the smaller elements, the pivot itself, and the larger elements.

Method to partition a sub-array into the smaller elements, the pivot itself, and the larger elements.

Type parameters

A

the type of the elements of data.

Value parameters

data

an array of elements of type A -- the array will be mutated.

from

the first index of the sub-array to be sorted.

pivot

the index of the pivot element to be used as the pivot (arbitrary).

to

the first index of the sub-array NOT to be sorted.

Attributes

Returns

the index at which we will now find the pivot.

final def qsort[A : Ordering : ClassTag](data: Array[A], from: Int, to: Int): Unit

Mutating method to sort a sub-array of the data array.

Mutating method to sort a sub-array of the data array.

Type parameters

A

the type of the elements of data.

Value parameters

data

an array of elements of type A -- the array will be mutated.

from

the first index of the sub-array to be sorted.

to

the first index of the sub-array NOT to be sorted.

Attributes

final def sort[A : Ordering : ClassTag](data: Array[A]): Unit

Mutating method to sort the data array.

Mutating method to sort the data array.

Type parameters

A

the type of the elements of data.

Value parameters

data

an array of elements of type A -- the array will be mutated.

Attributes