priorityqueue

package
v1.25.6 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item[T supportedValueType] struct {
	ID       uint64
	Dist     float32
	Rescored bool
	Value    T
}

Item represents a queue item supporting an optional additional Value

type Queue

type Queue[T supportedValueType] struct {
	// contains filtered or unexported fields
}

Queue is a priority queue supporting generic item values

func NewMax

func NewMax[T supportedValueType](capacity int) *Queue[T]

NewMax constructs a priority queue which prioritizes items with greater distance

func NewMin

func NewMin[T supportedValueType](capacity int) *Queue[T]

NewMin constructs a priority queue which prioritizes items with smaller distance

func (*Queue[T]) Cap

func (q *Queue[T]) Cap() int

Cap returns the remaining capacity of the queue

func (*Queue[T]) Insert

func (q *Queue[T]) Insert(id uint64, distance float32) int

Insert creates a valueless item and adds it to the queue

func (*Queue[T]) InsertWithValue added in v1.23.0

func (q *Queue[T]) InsertWithValue(id uint64, distance float32, val T) int

InsertWithValue creates an item with a T type value and adds it to the queue

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

Len returns the length of the queue

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() Item[T]

Pop removes the next item in the queue and returns it

func (*Queue[T]) Reset

func (q *Queue[T]) Reset()

Reset clears all items from the queue

func (*Queue[T]) ResetCap

func (q *Queue[T]) ResetCap(capacity int)

ResetCap drops existing queue items, and allocates a new queue with the given capacity

func (*Queue[T]) Top

func (q *Queue[T]) Top() Item[T]

Top peeks at the next item in the queue

Jump to

Keyboard shortcuts

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