dictx

package
v0.0.0-...-4da1013 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dictionary

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

func New

func New[K comparable, V any]() *Dictionary[K, V]

func (*Dictionary[K, V]) Clear

func (set *Dictionary[K, V]) Clear()

func (*Dictionary[K, V]) Clone

func (set *Dictionary[K, V]) Clone() (result *Dictionary[K, V])

func (*Dictionary[K, V]) Combine

func (set *Dictionary[K, V]) Combine(other IDictionary[K, V])

与other集合组合成新集合,相同键值时,other覆盖set

func (*Dictionary[K, V]) Count

func (set *Dictionary[K, V]) Count(cond func(key K, val V) bool) int

func (*Dictionary[K, V]) Delete

func (set *Dictionary[K, V]) Delete(key K)

func (*Dictionary[K, V]) Exists

func (set *Dictionary[K, V]) Exists(key K) bool

func (*Dictionary[K, V]) Filter

func (set *Dictionary[K, V]) Filter(cond func(key K, val V) bool) IDictionary[K, V]

返回符合条件的项形成的新集合

func (*Dictionary[K, V]) First

func (set *Dictionary[K, V]) First(handler func(key K, val V) bool) (result V)

func(key string, val V) bool{}

func (*Dictionary[K, V]) ForRange

func (set *Dictionary[K, V]) ForRange(handler func(key K, val V) (err error)) error

如果返回错误,迭代终止

func (*Dictionary[K, V]) Get

func (set *Dictionary[K, V]) Get(key K) (V, bool)

func (*Dictionary[K, V]) GetData

func (set *Dictionary[K, V]) GetData() map[K]V

func (*Dictionary[K, V]) Has

func (set *Dictionary[K, V]) Has(key K) bool

func (*Dictionary[K, V]) IsEmpty

func (set *Dictionary[K, V]) IsEmpty() bool

func (*Dictionary[K, V]) Items

func (set *Dictionary[K, V]) Items() (items []V)

func (*Dictionary[K, V]) Keys

func (set *Dictionary[K, V]) Keys() (keys []K)

func (*Dictionary[K, V]) Length

func (set *Dictionary[K, V]) Length() int

func (*Dictionary[K, V]) MustGet

func (set *Dictionary[K, V]) MustGet(key K) V

func (*Dictionary[K, V]) OnDelete

func (set *Dictionary[K, V]) OnDelete(handler func(key K, value V))

func (*Dictionary[K, V]) OnSet

func (set *Dictionary[K, V]) OnSet(handler func(key K, value V))

func (*Dictionary[K, V]) Pop

func (set *Dictionary[K, V]) Pop(key K) (v V, exists bool)

func (*Dictionary[K, V]) Reset

func (set *Dictionary[K, V]) Reset(data map[K]V)

不会触发onSet和onDelete

func (*Dictionary[K, V]) Set

func (set *Dictionary[K, V]) Set(key K, value V)

func (*Dictionary[K, V]) SetByMap

func (set *Dictionary[K, V]) SetByMap(m map[K]V)

func (*Dictionary[K, V]) SetBySet

func (set *Dictionary[K, V]) SetBySet(other IDictionary[K, V])

type IDictionary

type IDictionary[K comparable, V any] interface {
	GetData() map[K]V
	Reset(data map[K]V)
	Set(key K, value V)
	SetByMap(m map[K]V)
	SetBySet(other IDictionary[K, V])
	Get(key K) (V, bool)
	MustGet(key K) V
	Has(key K) bool
	Combine(other IDictionary[K, V])
	Delete(key K)
	Clear()
	Exists(key K) bool
	Length() int
	Pop(key K) (v V, exists bool)
	IsEmpty() bool
	Items() (items []V)
	Clone() (result *Dictionary[K, V])
	Keys() (keys []K)
	ForRange(handler func(key K, val V) (err error)) error
	First(handler func(key K, val V) bool) (result V)
	Filter(cond func(key K, val V) bool) IDictionary[K, V]
	Count(cond func(key K, val V) bool) int
	OnSet(handler func(key K, value V))
	OnDelete(handler func(key K, value V))
}

Jump to

Keyboard shortcuts

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