container

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Priority

type Priority interface{ int64 | float64 }

Priority defines the number types available to use as a priority value.

type PriorityQueue

type PriorityQueue[T comparable, P Priority] struct {
	// contains filtered or unexported fields
}

PriorityQueue provides a generic priority queue implementation with a built-in index for removals. https://pkg.go.dev/container/heap#example-package-PriorityQueue

func NewPriorityQueue

func NewPriorityQueue[T comparable, P Priority]() PriorityQueue[T, P]

NewPriorityQueue creates a new empty priority queue.

func (*PriorityQueue[T, P]) Len

func (pq *PriorityQueue[T, P]) Len() int

Len returns the number of elements in the queue.

func (*PriorityQueue[T, P]) Peek

func (pq *PriorityQueue[T, P]) Peek() (T, bool)

Peek returns the top element from the queue without removing it.

func (*PriorityQueue[T, P]) Pop

func (pq *PriorityQueue[T, P]) Pop() (T, bool)

Pop pops an element from the queue.

func (*PriorityQueue[T, P]) Push

func (pq *PriorityQueue[T, P]) Push(val T, pri P)

Push pushes an element into the queue.

func (*PriorityQueue[T, P]) Remove

func (pq *PriorityQueue[T, P]) Remove(val T) bool

Remove removes an arbitrary element from the queue.

type SyncMap

type SyncMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Thread-safe generic map.

func NewSyncMap

func NewSyncMap[K comparable, V any]() SyncMap[K, V]

func (*SyncMap[K, V]) Delete

func (s *SyncMap[K, V]) Delete(key K)

func (*SyncMap[K, V]) Load

func (s *SyncMap[K, V]) Load(key K) (V, bool)

func (*SyncMap[K, V]) Range

func (s *SyncMap[K, V]) Range(f func(k K, v V) bool)

func (*SyncMap[K, V]) Store

func (s *SyncMap[K, V]) Store(key K, val V)

Jump to

Keyboard shortcuts

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