container

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

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]) All added in v0.2.0

func (s *SyncMap[K, V]) All() iter.Seq2[K, V]

func (*SyncMap[K, V]) Del added in v0.2.0

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

func (*SyncMap[K, V]) Get added in v0.2.0

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

func (*SyncMap[K, V]) Set added in v0.2.0

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

Jump to

Keyboard shortcuts

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