maps

package
v0.0.0-...-0394936 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 11 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]) Copy

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

return Map copy

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 types.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]) Copy

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

return Map copy

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 WeightedMap

type WeightedMap[K comparable, V any] struct {
	Map[K, types.Weighted[V]]
	// contains filtered or unexported fields
}

WeightedMap is a map of Weighted values. Higher weight means higher priority (descending).

func NewWeighted

func NewWeighted[K comparable, V any](data map[K]types.Weighted[V]) *WeightedMap[K, V]

func NewWeightedMapFromSlice

func NewWeightedMapFromSlice[K comparable, V any](keys []K, data []V) *WeightedMap[K, V]

func (*WeightedMap[K, V]) Commit

func (m *WeightedMap[K, V]) Commit(fn func(data map[K]types.Weighted[V]))

run function with direct access to Map

func (*WeightedMap[K, V]) Copy

func (m *WeightedMap[K, V]) Copy() *WeightedMap[K, V]

return Map copy

func (*WeightedMap[K, V]) Delete

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

delete key from Map

func (*WeightedMap[K, V]) ForEach

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

range over Map

func (*WeightedMap[K, V]) Get

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

return value for key

func (*WeightedMap[K, V]) GetFull

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

return value and existence of key

func (*WeightedMap[K, V]) Iter

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

return iterator for safe iterating over Map

func (*WeightedMap[K, V]) Keys

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

return all Map keys

func (*WeightedMap[K, V]) MarshalCBOR

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

func (*WeightedMap[K, V]) MarshalJSON

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

func (*WeightedMap[K, V]) ReadOnly

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

func (*WeightedMap[K, V]) Safe

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

func (*WeightedMap[K, V]) Set

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

set value for key

func (*WeightedMap[K, V]) SetWeighted

func (m *WeightedMap[K, V]) SetWeighted(k K, v types.Weighted[V])

set value for key with weight

func (*WeightedMap[K, V]) String

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

func (*WeightedMap[K, V]) UnmarshalCBOR

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

func (*WeightedMap[K, V]) UnmarshalJSON

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

func (*WeightedMap[K, V]) Values

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

return all Map values

func (*WeightedMap[K, V]) WeightIter

func (m *WeightedMap[K, V]) WeightIter() <-chan types.Iterator[K, V]

WeightIter... Returned iterators are in descending order.

Jump to

Keyboard shortcuts

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