mergesort

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package heap provides heap operations for any type that implements heap.Interface. A heap is a tree with the property that each node is the minimum-valued node in its subtree.

The minimum element in the tree is the root, at index 0.

A heap is a common way to implement a priority queue. To build a priority queue, implement the Heap interface with the (negative) priority as the ordering for the Less method, so Push adds items while Pop removes the highest-priority item from the queue. The Examples include such an implementation; the file example_pq_test.go has the complete source.

Package sort provides primitives for sorting slices and user-defined collections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Merge added in v0.8.0

func Merge[T any](
	col []containers.Vector,
	src *[]uint32,
	lessFunc LessFunc[T],
	fromLayout,
	toLayout []uint32,
	pool *containers.VectorPool,
) (ret []containers.Vector, mapping []uint32)

func MergeSortedColumn

func MergeSortedColumn(
	column []containers.Vector, sortedIdx *[]uint32, fromLayout, toLayout []uint32, pool *containers.VectorPool,
) (ret []containers.Vector, mapping []uint32)

func Multiplex

func Multiplex(
	col []containers.Vector, src []uint32, fromLayout, toLayout []uint32, pool *containers.VectorPool,
) (ret []containers.Vector)

func Reshape

func Reshape(
	column []containers.Vector, fromLayout, toLayout []uint32, pool *containers.VectorPool,
) (ret []containers.Vector)

func Shuffle

func Shuffle(
	col containers.Vector, idx []int32, pool *containers.VectorPool,
) containers.Vector

func ShuffleColumn

func ShuffleColumn(
	column []containers.Vector, sortedIdx []uint32, fromLayout, toLayout []uint32, pool *containers.VectorPool,
) (ret []containers.Vector)

func Sort added in v0.8.0

func Sort[T any](col containers.Vector, lessFunc LessFunc[T], idx []int32) (ret containers.Vector)

func SortBlockColumns

func SortBlockColumns(
	cols []containers.Vector, pk int, pool *containers.VectorPool,
) ([]int32, error)

Types

type HeapElem added in v0.8.0

type HeapElem[T any] struct {
	// contains filtered or unexported fields
}

type HeapSlice added in v0.8.0

type HeapSlice[T any] struct {
	// contains filtered or unexported fields
}

func NewHeapSlice added in v0.8.0

func NewHeapSlice[T any](n int, lessFunc LessFunc[T]) HeapSlice[T]

func (*HeapSlice[T]) Append added in v0.8.0

func (x *HeapSlice[T]) Append(elem HeapElem[T])

func (*HeapSlice[T]) AsSlice added in v0.8.0

func (x *HeapSlice[T]) AsSlice() []HeapElem[T]

func (*HeapSlice[T]) Less added in v0.8.0

func (x *HeapSlice[T]) Less(i, j int) bool

func (*HeapSlice[T]) Swap added in v0.8.0

func (x *HeapSlice[T]) Swap(i, j int)

type LessFunc added in v0.8.0

type LessFunc[T any] func(a, b T) bool

type Lter added in v0.8.0

type Lter[T any] interface {
	Lt(b T) bool
}

uuid && decimal

type SortElem added in v0.8.0

type SortElem[T any] struct {
	// contains filtered or unexported fields
}

type SortSlice added in v0.8.0

type SortSlice[T any] struct {
	// contains filtered or unexported fields
}

func NewSortSlice added in v0.8.0

func NewSortSlice[T any](n int, lessFunc LessFunc[T]) SortSlice[T]

func (*SortSlice[T]) Append added in v0.8.0

func (x *SortSlice[T]) Append(elem SortElem[T])

func (*SortSlice[T]) AsSlice added in v0.8.0

func (x *SortSlice[T]) AsSlice() []SortElem[T]

func (*SortSlice[T]) Less added in v0.8.0

func (x *SortSlice[T]) Less(i, j int) bool

func (*SortSlice[T]) Swap added in v0.8.0

func (x *SortSlice[T]) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL