Documentation ¶
Overview ¶
Package sort a package for demonstrating sorting algorithms in Go
Index ¶
- func Bubble[T constraints.Ordered](arr []T) []T
- func Comb[T constraints.Ordered](data []T) []T
- func Count[T constraints.Number](data []int) []int
- func Exchange[T constraints.Ordered](arr []T) []T
- func HeapSort[T constraints.Ordered](slice []T) []T
- func ImprovedSimple[T constraints.Ordered](arr []T) []T
- func Insertion[T constraints.Ordered](arr []T) []T
- func Merge[T constraints.Ordered](items []T) []T
- func MergeIter[T constraints.Ordered](items []T) []T
- func ParallelMerge[T constraints.Ordered](items []T) []T
- func Partition[T constraints.Ordered](arr []T, low, high int) int
- func Patience[T constraints.Ordered](arr []T) []T
- func Pigeonhole[T constraints.Integer](arr []T) []T
- func Quicksort[T constraints.Ordered](arr []T) []T
- func QuicksortRange[T constraints.Ordered](arr []T, low, high int)
- func RadixSort[T constraints.Integer](arr []T) []T
- func Selection[T constraints.Ordered](arr []T) []T
- func Shell[T constraints.Ordered](arr []T) []T
- func Simple[T constraints.Ordered](arr []T) []T
- type Comparable
- type MaxHeap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bubble ¶
func Bubble[T constraints.Ordered](arr []T) []T
Bubble is a simple generic definition of Bubble sort algorithm.
func Comb ¶
func Comb[T constraints.Ordered](data []T) []T
Comb is a simple sorting algorithm which is an improvement of the bubble sorting algorithm.
func Exchange ¶
func Exchange[T constraints.Ordered](arr []T) []T
func HeapSort ¶
func HeapSort[T constraints.Ordered](slice []T) []T
func ImprovedSimple ¶
func ImprovedSimple[T constraints.Ordered](arr []T) []T
ImprovedSimple is a improve SimpleSort by skipping an unnecessary comparison of the first and last. This improved version is more similar to implementation of insertion sort
func Insertion ¶
func Insertion[T constraints.Ordered](arr []T) []T
func MergeIter ¶
func MergeIter[T constraints.Ordered](items []T) []T
func ParallelMerge ¶
func ParallelMerge[T constraints.Ordered](items []T) []T
ParallelMerge Perform merge sort on a slice using goroutines
func Patience ¶
func Patience[T constraints.Ordered](arr []T) []T
func Pigeonhole ¶
func Pigeonhole[T constraints.Integer](arr []T) []T
Pigeonhole sorts a slice using pigeonhole sorting algorithm. NOTE: To maintain time complexity O(n + N), this is the reason for having only Integer constraint instead of Ordered.
func Quicksort ¶
func Quicksort[T constraints.Ordered](arr []T) []T
Quicksort Sorts the entire array
func QuicksortRange ¶
func QuicksortRange[T constraints.Ordered](arr []T, low, high int)
QuicksortRange Sorts the specified range within the array
func RadixSort ¶
func RadixSort[T constraints.Integer](arr []T) []T
func Selection ¶
func Selection[T constraints.Ordered](arr []T) []T
func Shell ¶
func Shell[T constraints.Ordered](arr []T) []T
func Simple ¶
func Simple[T constraints.Ordered](arr []T) []T
Types ¶
type Comparable ¶
type MaxHeap ¶
type MaxHeap struct {
// contains filtered or unexported fields
}
func (*MaxHeap) Init ¶
func (h *MaxHeap) Init(slice []Comparable)
func (*MaxHeap) Pop ¶
func (h *MaxHeap) Pop() Comparable
func (*MaxHeap) Push ¶
func (h *MaxHeap) Push(i Comparable)
func (MaxHeap) Update ¶
func (h MaxHeap) Update(i Comparable)