container

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 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 PriorityMap added in v0.1.1

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

PriorityMap provides a map with a built-in priority queue for trimming.

func NewPriorityMap added in v0.1.1

func NewPriorityMap[K comparable, V any, P Priority]() PriorityMap[K, V, P]

NewPriorityMap creates a new empty priority queue.

func (*PriorityMap[K, V, P]) Delete added in v0.1.1

func (p *PriorityMap[K, V, P]) Delete(key K)

Delete an element from the map.

func (*PriorityMap[K, V, P]) Find added in v0.1.1

func (p *PriorityMap[K, V, P]) Find(cond func(V) bool) (V, bool)

Find a value in the map with a given condition.

func (*PriorityMap[K, V, P]) Get added in v0.1.1

func (p *PriorityMap[K, V, P]) Get(key K) (V, bool)

Get an element in the map by its key.

func (*PriorityMap[K, V, P]) Len added in v0.1.1

func (p *PriorityMap[K, V, P]) Len() int

Len returns the number of elements in the queue.

func (*PriorityMap[K, V, P]) Next added in v0.1.1

func (p *PriorityMap[K, V, P]) Next() (K, V, bool)

Next returns the next value in the map with the lowest priority.

func (*PriorityMap[K, V, P]) Set added in v0.1.1

func (p *PriorityMap[K, V, P]) Set(key K, val V, pri P)

Set an element in the map to the given value and priority.

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