kheap

package
v0.11.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HeapItem

type HeapItem interface {
	Data() interface{} // The data object
	Score() float64    // Score to use as the sort criteria
}

HeapItem is an interface type implemented by objects stored in the ScoreHeap

type ScoreHeap

type ScoreHeap struct {
	// contains filtered or unexported fields
}

A ScoreHeap implements heap.Interface and is a min heap that keeps the top K elements by Score. Push can be called with an arbitrary number of values but only the top K are stored

func NewScoreHeap

func NewScoreHeap(capacity uint32) *ScoreHeap

func (*ScoreHeap) GetItemsReverse

func (pq *ScoreHeap) GetItemsReverse() []interface{}

GetItemsReverse returns the items in this min heap in reverse order sorted by score descending

func (ScoreHeap) Len

func (pq ScoreHeap) Len() int

func (ScoreHeap) Less

func (pq ScoreHeap) Less(i, j int) bool

func (*ScoreHeap) Pop

func (pq *ScoreHeap) Pop() interface{}

Push implements heap.Interface and returns the top K scoring elements in increasing order of Score. Callers must reverse the order of returned elements to get the top K scoring elements in descending order

func (*ScoreHeap) Push

func (pq *ScoreHeap) Push(x interface{})

Push implements heap.Interface and only stores the top K elements by Score

func (ScoreHeap) Swap

func (pq ScoreHeap) Swap(i, j int)

Jump to

Keyboard shortcuts

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