queue

package
v1.8.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: AGPL-3.0 Imports: 2 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 any] struct {
	Value    T
	Priority int
	// contains filtered or unexported fields
}

Item stores the attributes which will be pushed to the priority queue..

type PriorityQueue

type PriorityQueue[T any] []*Item[T]

PriorityQueue provides a heap.Interface compatible priority queue for the Item type. The actual Item.index in the queue is controlled by the Item.Priority and Item.timeStamp.

func (*PriorityQueue[T]) GetIndex

func (pq *PriorityQueue[T]) GetIndex(x interface{}) int

GetIndex returns the index of the corresponding element.

func (PriorityQueue[T]) Len

func (pq PriorityQueue[T]) Len() int

Len: Size of the priority queue . Used to satisfy the heap interface...

func (PriorityQueue[T]) Less

func (pq PriorityQueue[T]) Less(i, j int) bool

Less is used to compare elements and store them in the proper order in priority queue.

func (*PriorityQueue[T]) Pop

func (pq *PriorityQueue[T]) Pop() interface{}

Pop removes elements from the priority queue

func (*PriorityQueue[T]) Push

func (pq *PriorityQueue[T]) Push(x interface{})

Push adds elements to the priority queue

func (PriorityQueue[T]) Swap

func (pq PriorityQueue[T]) Swap(i, j int)

Swap is used to swap the values in the priority queue.

func (*PriorityQueue[T]) Top

func (pq *PriorityQueue[T]) Top() interface{}

Top returns the topmost element in the priority queue

func (*PriorityQueue[T]) Update

func (pq *PriorityQueue[T]) Update(item *Item[T], priority int)

Update updates the attributes of an element in the priority queue.

Jump to

Keyboard shortcuts

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