maps

package
v0.0.0-...-80fb781 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare[K, T comparable](a, b map[K]T) bool

Types

type Bucket

type Bucket[V any] struct {
	// contains filtered or unexported fields
}

func NewBucket

func NewBucket[V any](m *Map[string, V], pfx string) *Bucket[V]

func (Bucket[V]) Bucket

func (b Bucket[V]) Bucket(pfx string) *Bucket[V]

func (Bucket[V]) Delete

func (b Bucket[V]) Delete(k string)

func (Bucket[V]) Exists

func (b Bucket[V]) Exists(k string) bool

func (Bucket[V]) ForEach

func (b Bucket[V]) ForEach(fn func(k string, v V))

func (Bucket[V]) Get

func (b Bucket[V]) Get(k string) V

func (Bucket[V]) GetFull

func (b Bucket[V]) GetFull(k string) (V, bool)

func (Bucket[V]) Iter

func (b Bucket[V]) Iter() types.Iterator[string, V]

func (Bucket[V]) Keys

func (b Bucket[V]) Keys() (keys []string)

func (Bucket[V]) Len

func (b Bucket[V]) Len() int

func (Bucket[V]) Set

func (b Bucket[V]) Set(k string, v V)

func (Bucket[V]) Values

func (b Bucket[V]) Values() (values []V)

func (Bucket[V]) Watch

func (b Bucket[V]) Watch(ctx context.Context) types.Watcher[string, V]

type Map

type Map[K comparable, V any] struct {
	*channel.Hub[types.WatchMsg[K, V]]
	// contains filtered or unexported fields
}

func New

func New[K comparable, V any](data map[K]V) *Map[K, V]

func (*Map[K, V]) Commit

func (m *Map[K, V]) Commit(fn func(data map[K]V))

run function with direct access to Map

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(k K)

delete key from Map

func (*Map[K, V]) Eventfull

func (m *Map[K, V]) Eventfull(ctx context.Context, buf int) *Map[K, V]

retrun map with event chan

func (*Map[K, V]) Exists

func (m *Map[K, V]) Exists(k K) bool

return key existence

func (*Map[K, V]) ForEach

func (m *Map[K, V]) ForEach(fn func(k K, v V))

range over Map

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(k K) V

return value for key

func (*Map[K, V]) GetFull

func (m *Map[K, V]) GetFull(k K) (obj V, exists bool)

return value and existence of key

func (*Map[K, V]) Iter

func (m *Map[K, V]) Iter() types.Iterator[K, V]

return iterator for safe iterating over Map

func (*Map[K, V]) Keys

func (m *Map[K, V]) Keys() (keys []K)

return all Map keys

func (*Map[K, V]) Len

func (m *Map[K, V]) Len() int

return Map length

func (*Map[K, V]) MarshalCBOR

func (m *Map[K, V]) MarshalCBOR() ([]byte, error)

func (*Map[K, V]) MarshalJSON

func (m *Map[K, V]) MarshalJSON() ([]byte, error)

func (*Map[K, V]) ReadOnly

func (m *Map[K, V]) ReadOnly() *Map[K, V]

return ReadOnly Map

func (*Map[K, V]) Safe

func (m *Map[K, V]) Safe() *Map[K, V]

return Safe Map

func (*Map[K, V]) Set

func (m *Map[K, V]) Set(k K, v V)

set value for key

func (*Map[K, V]) String

func (m *Map[K, V]) String() string

func (*Map[K, V]) UnmarshalCBOR

func (m *Map[K, V]) UnmarshalCBOR(data []byte) error

func (*Map[K, V]) UnmarshalJSON

func (m *Map[K, V]) UnmarshalJSON(data []byte) error

func (*Map[K, V]) Values

func (m *Map[K, V]) Values() (values []V)

return all Map values

type OrderedMap

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

func NewOrdered

func NewOrdered[K constraints.Ordered, V any](data map[K]V, lessFunc SortFunction[K]) *OrderedMap[K, V]

func (*OrderedMap[K, V]) Commit

func (m *OrderedMap[K, V]) Commit(fn func(data map[K]V))

run function with direct access to Map

func (*OrderedMap[K, V]) Delete

func (m *OrderedMap[K, V]) Delete(k K)

delete key from Map

func (*OrderedMap[K, V]) ForEach

func (m *OrderedMap[K, V]) ForEach(fn func(k K, v V))

range over Map

func (*OrderedMap[K, V]) Iter

func (m *OrderedMap[K, V]) Iter() types.Iterator[K, V]

return iterator for safe iterating over Map

func (*OrderedMap[K, V]) Keys

func (m *OrderedMap[K, V]) Keys() (keys []K)

return all Map keys

func (*OrderedMap[K, V]) ReadOnly

func (m *OrderedMap[K, V]) ReadOnly() *OrderedMap[K, V]

return ReadOnly Map

func (*OrderedMap[K, V]) Safe

func (m *OrderedMap[K, V]) Safe() *OrderedMap[K, V]

return Safe Map

func (*OrderedMap[K, V]) Set

func (m *OrderedMap[K, V]) Set(k K, v V)

set value for key

func (*OrderedMap[K, V]) Values

func (m *OrderedMap[K, V]) Values() (values []V)

return all Map values

type SortFunction

type SortFunction[K constraints.Ordered] func(data []K, i, j int) bool

Jump to

Keyboard shortcuts

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