topk

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 3 Imported by: 0

README

topk

A data structure for finding the top k elements

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

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

An Item is something we manage in a priority queue.

type PriorityQueue

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

A PriorityQueue implements heap.Interface and holds Items.

func NewPriorityQueueForTopK

func NewPriorityQueueForTopK(k int) *PriorityQueue

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

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

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() any

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x any)

func (PriorityQueue) Swap

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

func (*PriorityQueue) Top

func (pq *PriorityQueue) Top() *Item

func (*PriorityQueue) TryPush

func (pq *PriorityQueue) TryPush(x any)

type TOPK

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

func NewTOPK

func NewTOPK(k int) *TOPK

func (*TOPK) Add

func (topk *TOPK) Add(item *Item)

func (*TOPK) Add2 added in v0.0.2

func (topk *TOPK) Add2(value int, priority int)

func (*TOPK) Dump added in v0.0.2

func (topk *TOPK) Dump()

func (*TOPK) Dumps added in v0.0.3

func (topk *TOPK) Dumps() string

func (*TOPK) Init

func (topk *TOPK) Init()

Jump to

Keyboard shortcuts

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