heap

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elem

type Elem struct {
	Value  int32
	Weight float32
}

type PriorityQueue

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

PriorityQueue represents the priority queue.

func NewPriorityQueue

func NewPriorityQueue(desc bool) *PriorityQueue

NewPriorityQueue initializes an empty priority queue.

func (*PriorityQueue) Clone

func (p *PriorityQueue) Clone() *PriorityQueue

func (*PriorityQueue) Elems

func (p *PriorityQueue) Elems() []Elem

func (*PriorityQueue) Len

func (e *PriorityQueue) Len() int

func (*PriorityQueue) Less

func (e *PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Peek

func (p *PriorityQueue) Peek() (int32, float32)

func (*PriorityQueue) Pop

func (p *PriorityQueue) Pop() (int32, float32)

Pop removes the element with the highest priority from the queue and returns it. In case of an empty queue, an error is returned.

func (*PriorityQueue) Push

func (p *PriorityQueue) Push(v int32, weight float32)

Push inserts a new element into the queue. No action is performed on duplicate elements.

func (*PriorityQueue) Reverse

func (p *PriorityQueue) Reverse() *PriorityQueue

func (*PriorityQueue) Swap

func (e *PriorityQueue) Swap(i, j int)

func (*PriorityQueue) Values

func (p *PriorityQueue) Values() []int32

type TopKFilter

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

TopKFilter filters out top k items with maximum weights.

func NewTopKFilter

func NewTopKFilter(k int) *TopKFilter

NewTopKFilter creates a top k filter.

func (*TopKFilter) Len

func (e *TopKFilter) Len() int

func (*TopKFilter) Less

func (e *TopKFilter) Less(i, j int) bool

func (*TopKFilter) Pop

func (e *TopKFilter) Pop() interface{}

func (*TopKFilter) PopAll

func (filter *TopKFilter) PopAll() ([]int32, []float32)

PopAll pops all items in the filter with decreasing order.

func (*TopKFilter) Push

func (filter *TopKFilter) Push(item int32, weight float32)

Push pushes the element x onto the heap. The complexity is O(log n) where n = h.Count().

func (*TopKFilter) Swap

func (e *TopKFilter) Swap(i, j int)

type TopKStringFilter

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

TopKStringFilter filters out top k strings with maximum weights.

func NewTopKStringFilter

func NewTopKStringFilter(k int) *TopKStringFilter

NewTopKStringFilter creates a top k string filter.

func (*TopKStringFilter) Len

func (filter *TopKStringFilter) Len() int

func (*TopKStringFilter) Less

func (filter *TopKStringFilter) Less(i, j int) bool

func (*TopKStringFilter) PopAll

func (filter *TopKStringFilter) PopAll() ([]string, []float64)

PopAll pops all strings in the filter with decreasing order.

func (*TopKStringFilter) Push

func (filter *TopKStringFilter) Push(item string, weight float64)

Push pushes the element x onto the heap. The complexity is O(log n) where n = h.Count().

func (*TopKStringFilter) Swap

func (filter *TopKStringFilter) Swap(i, j int)

Jump to

Keyboard shortcuts

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