priorityqueue

package
v0.0.0-...-861ca8c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

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

Queue std::priority_queue

func New

func New[T any](slicePtr *[]T, less func(a, b T) bool) *Queue[T]

New PriorityQueue

slicePtr can be nil, then it will be initialized as []T{}

less can't be nil, it's the compare function less(i, j int) { return a[i]<b[i] } is min-heap

func (Queue[T]) IsEmpty

func (q Queue[T]) IsEmpty() bool

Empty len(slice) == 0

func (Queue[T]) Pop

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

Pop priority_queue.pop() with result

func (Queue[T]) Push

func (q Queue[T]) Push(x T)

Push priority_queue.push(x)

func (Queue[T]) Size

func (q Queue[T]) Size() int

Size len(slice)

func (Queue[T]) Top

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

Top slice[0]

Jump to

Keyboard shortcuts

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