datastructure

package
v0.0.0-...-bf7c6ad Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 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 Item

type Item struct {
	Value    any // The Value of the item; arbitrary.
	Priority int // The Priority of the item in the queue.
	// contains filtered or unexported fields
}

An Item is something we manage in a Priority queue.

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

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) Update

func (pq *PriorityQueue) Update(item *Item, value any, priority int)

Update modifies the Priority and Value of an Item in the queue.

type Queue

type Queue []any

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

func (*Queue) Pop

func (q *Queue) Pop() any

func (*Queue) Push

func (q *Queue) Push(item any)

Jump to

Keyboard shortcuts

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