pqueue

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2025 License: MIT Imports: 3 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 interface {
	Less(another Item) bool
}

type PQueue

type PQueue[T Item] struct {
	// contains filtered or unexported fields
}

func New

func New[T Item](opts ...PQueueOption[T]) *PQueue[T]

Defaults to a queue which prioritises a higher priority

func (*PQueue[T]) Iter

func (q *PQueue[T]) Iter() iter.Iterator[T]

func (*PQueue[T]) IterClone

func (q *PQueue[T]) IterClone() iter.Iterator[T]

Creates an immutable clone of the original

func (PQueue[T]) Len

func (q PQueue[T]) Len() int

func (PQueue[T]) Less

func (q PQueue[T]) Less(i int, j int) bool

func (*PQueue[T]) Pop

func (q *PQueue[T]) Pop() any

Will return nil if empty

func (*PQueue[T]) Push

func (q *PQueue[T]) Push(v any)

func (PQueue[T]) Swap

func (q PQueue[T]) Swap(i int, j int)

type PQueueOption

type PQueueOption[T Item] func(*PQueue[T])

func WithCapacity

func WithCapacity[T Item](capacity int) PQueueOption[T]

func WithItems

func WithItems[T Item](items ...T) PQueueOption[T]

func WithPriority

func WithPriority[T Item](priority PriorityType) PQueueOption[T]

type PriorityType

type PriorityType int
const (
	PriorityMin PriorityType = iota
	PriorityMax
)

Jump to

Keyboard shortcuts

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