MergeSort

object MergeSort extends Sort

In-place merge sort implementation. This sort is stable but does mutate the given array. It is an in-place sort but it does allocate a temporary array of the same size as the input. It uses InsertionSort for sorting very small arrays.

trait Sort
class Object
trait Matchable
class Any

Value members

Concrete methods

@inline
final
def merge[@specialized A](in: Array[A], out: Array[A], start: Int, mid: Int, end: Int)(implicit o: Order[A]): Unit

Helper method for mergeSort, used to do a single "merge" between two sections of the input array, and write the result to the output array.

Helper method for mergeSort, used to do a single "merge" between two sections of the input array, and write the result to the output array.

The first input section starts at start (inclusive) and ends at mid (exclusive). The second input section starts at mid (inclusive) and ends at end (exclusive).

Writing to the output begins at start (inclusive).

Type Params
A

a member of the type class Order

Value Params
end

the end of the second input section (exclusive)

in

the input array

mid

the end of the first input section (exclusive) and the beginning of the second input section (inclusive)

out

the output array

start

the start of the first input section (inclusive) as well as the start of the merged output

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

Uses merge sort to sort the array data in place.

Uses merge sort to sort the array data in place.

If the size of the input array does not exceed the threshold startStep, uses insertion sort instead.

Type Params
A

a member of the type class Order

Value Params
data

the array to be sorted

@inline
final
def startStep: Int
@inline
final
def startWidth: Int