com.phasmidsoftware.sort

Members list

Type members

Classlikes

object InsertionSort extends Sort

Simple implementation of insertion sort.

Simple implementation of insertion sort.

Works for small arrays but due to quadratic complexity is not generally good, unless array is partially sorted.

Attributes

Supertypes
trait Sort
class Object
trait Matchable
class Any
Self type
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.

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.

Attributes

Supertypes
trait Sort
class Object
trait Matchable
class Any
Self type
MergeSort.type
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.

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

Supertypes
class Object
trait Matchable
class Any
Self type
QuickSort.type
trait Sort extends Any

Interface for a sorting strategy object.

Interface for a sorting strategy object.

Attributes

Supertypes
class Any
Known subtypes
object InsertionSort
object MergeSort
object Sorted

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Sorted.type
case class Sorted[T](ts: Seq[T])(using comparer: Comparer[T], ct: ClassTag[T]) extends () => Seq[T]

Case class Sorted to enable different types of sort on a sequence.

Case class Sorted to enable different types of sort on a sequence.

This is not really part of the Comparer/Comparison code and should probably not be here.

Type parameters

T

the underlying type of the sequence.

Value parameters

comparer

the Comparer[T] which determines the order.

ct

the ClassTag[T].

ts

a sequence of T values.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait () => Seq[T]
class Object
trait Matchable
class Any
Show all
object Sorting

Object providing in-place sorting capability for arrays.

Object providing in-place sorting capability for arrays.

Sorting.sort() uses quickSort() by default (in-place, not stable, generally fastest but might hit bad cases where it's quadratic. Also provides mergeSort() (in-place, stable, uses extra memory, still pretty fast) and insertionSort(), which is slow except for small arrays.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Sorting.type