queue

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-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 Assigner

type Assigner interface {
	AssignPriority(item Item) func() float32
}

type Item

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

Item represents an item in the priority queue.

func (Item) GetValue added in v0.1.2

func (i Item) GetValue() interface{}

type PriorityQueue

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

PriorityQueue implements a priority queue.

func NewPriorityQueue added in v0.1.3

func NewPriorityQueue(assigner Assigner) *PriorityQueue

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

Len returns the length of the priority queue.

func (PriorityQueue) Less

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

Less checks if the item at index i has higher priority than the item at index j.

func (*PriorityQueue) Pop

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

Pop removes and returns the item with the highest priority from the priority queue.

func (*PriorityQueue) Push

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

Push adds an item to the priority queue.

func (PriorityQueue) Swap

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

Swap swaps the items at indexes i and j.

func (*PriorityQueue) Update

func (pq *PriorityQueue) Update(item *Item, value interface{})

Update modifies the priority and value of an item in the priority queue.

Jump to

Keyboard shortcuts

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