kheap

package
v0.9.1-spreadfix Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: MPL-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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