Documentation
¶
Index ¶
- type Sorter
- func Binary[T any](comparator comparables.Comparator[T]) Sorter[T]
- func Get[T Sorter[S], S prim.Ordered]() Sorter[S]
- func Merge[T prim.Ordered](comparator comparables.Comparator[T]) Sorter[T]
- func Native[T any](comparator comparables.Comparator[T]) Sorter[T]
- func Quick[T any](comparator comparables.Comparator[T]) Sorter[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sorter ¶
type Sorter[T any] interface { Sort(arr *[]T) SortP(arr *[]*T) }
func Binary ¶
func Binary[T any](comparator comparables.Comparator[T]) Sorter[T]
func Get ¶
Get returns a new instance of the Sorter interface using the default comparator.
The implementation will depend on the type parameter T. If T is a mergeSorter, Quick or binarySorter, the respective Sorter instance will be returned. Otherwise, the Native Sorter will be returned.
Note: The default comparator is an instance of comparables.Ordered[S]{}, which is the default comparator for the given type S.
func Merge ¶
func Merge[T prim.Ordered](comparator comparables.Comparator[T]) Sorter[T]
func Native ¶
func Native[T any](comparator comparables.Comparator[T]) Sorter[T]
Native returns a Sorter that uses the native sort function from the standard library.
func Quick ¶
func Quick[T any](comparator comparables.Comparator[T]) Sorter[T]
Quick creates a new instance of Sorter that uses the quickSorter with the given comparator. The comparator is used to compare elements in the array during the sorting process.
Parameters: - comparator: A function that takes two elements of type T and returns a boolean indicating their order.
Returns: - *quickSorter[T]: A pointer to the newly created quickSorter struct.