collect

package
v0.0.0-...-32c7374 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUniquePriorityQueue

func NewUniquePriorityQueue[T comparable, P constraints.Ordered](
	items ...PriorityQueueItem[T, P]) *uniquePriorityQueue[T, P]

NewUniquePriorityQueue returns a unique priority queue.

Types

type OrderedMap

type OrderedMap[K comparable, V any] = orderedmap.OrderedMap[K, V]

OrderedMap is a map that maintains the insertion order of items.

func NewOrderedMap

func NewOrderedMap[K comparable, V any]() OrderedMap[K, V]

NewOrderedMap returns a new ordered map.

func NewOrderedMapCap

func NewOrderedMapCap[K comparable, V any](cap int) OrderedMap[K, V]

NewOrderedMapCap returns a new ordered map with the given capacity.

type PriorityQueue

type PriorityQueue[T any, P any] interface {
	// Len returns the number of elements in the queue.
	Len() int

	// Clear removes all elements from the queue.
	Clear()

	// Poll removes and returns the minimum element (according to Less) from the queue.
	Poll() (value T, priority P, ok bool)

	// Push pushes an element onto the queue.
	Push(value T, priority P)
}

PriorityQueue is a priority queue.

func NewPriorityQueue

func NewPriorityQueue[T any, P constraints.Ordered](
	items ...PriorityQueueItem[T, P]) PriorityQueue[T, P]

NewPriorityQueue returns a new priority queue with an ordered priority.

func NewPriorityQueueCompare

func NewPriorityQueueCompare[T any, P any](compare compare.Compare[P],
	items ...PriorityQueueItem[T, P]) PriorityQueue[T, P]

NewPriorityQueueCompare returns a new priority queue with a priority compare function.

type PriorityQueueItem

type PriorityQueueItem[T any, P any] struct {
	Value    T
	Priority P
}

PriorityQueueItem is an element of the queue.

type UniquePriorityQueue

type UniquePriorityQueue[T comparable, P any] interface {
	// Len returns the number of elements in the queue.
	Len() int

	// Clear removes all elements from the queue.
	Clear()

	// Contains returns true if the queue contains an element.
	Contains(value T) bool

	// Get returns the priority of an element.
	Get(value T) (p P, ok bool)

	// Push pushes an element onto the queue, or updates its priority.
	Push(value T, priority P)

	// Poll removes and returns the minimum element (according to Less) from the queue.
	Poll() (value T, priority P, ok bool)

	// Remove removes an element from the queue, and returns its priority.
	Remove(value T) (p P, ok bool)
}

UniquePriorityQueue is a priority queue that contains unique elements.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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