cmap

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CMap

type CMap[K constraints.Ordered, V any] struct {
	// contains filtered or unexported fields
}

func New

func New[K constraints.Ordered, V any]() (c *CMap[K, V])

func (*CMap[K, V]) Delete

func (c *CMap[K, V]) Delete(key K)

删除

func (*CMap[K, V]) Iter

func (c *CMap[K, V]) Iter() (rv chan Pair[K, V])

func (*CMap[K, V]) Keys

func (c *CMap[K, V]) Keys() []K

TODO 优化

func (*CMap[K, V]) Len

func (c *CMap[K, V]) Len() int

func (*CMap[K, V]) Load

func (c *CMap[K, V]) Load(key K) (value V, ok bool)

func (*CMap[K, V]) LoadAndDelete

func (c *CMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)

func (*CMap[K, V]) LoadOrStore

func (c *CMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)

func (*CMap[K, V]) Range

func (c *CMap[K, V]) Range(f func(key K, value V) bool)

func (*CMap[K, V]) Store

func (c *CMap[K, V]) Store(key K, value V)

func (*CMap[K, V]) UpdateOrInsert added in v0.0.9

func (c *CMap[K, V]) UpdateOrInsert(k K, cb UpdataOrInsertCb[K, V])

删除或者更新

func (*CMap[K, V]) Values

func (c *CMap[K, V]) Values() []V

type Item

type Item[K constraints.Ordered, V any] struct {
	// contains filtered or unexported fields
}

type Pair

type Pair[K constraints.Ordered, V any] struct {
	Key K
	Val V
}

type UpdataOrInsertCb added in v0.0.9

type UpdataOrInsertCb[K constraints.Ordered, V any] func(exist bool, old V) (newVal V)

Jump to

Keyboard shortcuts

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