Documentation ¶
Index ¶
- Variables
- func AnyElem[K comparable, V any, M ~map[K]V](m M) (K, V)
- func Equals[K, V comparable, M ~map[K]V](a, b M) (equal bool)
- type Bucket
- func (b Bucket[V]) Bucket(pfx string) *Bucket[V]
- func (b Bucket[V]) Delete(k string)
- func (b Bucket[V]) Exists(k string) bool
- func (b Bucket[V]) ForEach(fn func(k string, v V) error) error
- func (b Bucket[V]) Get(k string) V
- func (b Bucket[V]) GetFull(k string) (V, bool)
- func (b Bucket[V]) Iter() types.Iterator[string, V]
- func (b Bucket[V]) Keys() (keys []string)
- func (b Bucket[V]) Len() int
- func (b Bucket[V]) Set(k string, v V)
- func (b Bucket[V]) Values() (values []V)
- func (b Bucket[V]) Watch(ctx context.Context) types.Watcher[string, V]
- type EventfulMap
- type EventfulMaper
- type Map
- func (m *Map[K, V]) Commit(fn func(data map[K]V))
- func (m *Map[K, V]) Copy() Maper[K, V]
- func (m *Map[K, V]) Delete(k K)
- func (m *Map[K, V]) Eventful(ctx context.Context, buf int) *EventfulMap[K, V]
- func (m *Map[K, V]) Exists(k K) bool
- func (m *Map[K, V]) ForEach(fn func(k K, v V) error) error
- func (m *Map[K, V]) Get(k K) V
- func (m *Map[K, V]) GetFull(k K) (obj V, exists bool)
- func (m *Map[K, V]) Iter() types.Iterator[K, V]
- func (m *Map[K, V]) Keys() (keys []K)
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) MarshalCBOR() ([]byte, error)
- func (m *Map[K, V]) MarshalJSON() ([]byte, error)
- func (m *Map[K, V]) Raw() map[K]V
- func (m *Map[K, V]) ReadOnly() *ReadOnlyMap[K, V]
- func (m *Map[K, V]) Safe() *SafeMap[K, V]
- func (m *Map[K, V]) Set(k K, v V)
- func (m *Map[K, V]) String() string
- func (m *Map[K, V]) UnmarshalCBOR(data []byte) error
- func (m *Map[K, V]) UnmarshalJSON(data []byte) error
- func (m *Map[K, V]) Values() (values []V)
- type MapConverter
- type Maper
- type OrderedMap
- func NewOrdered[K constraints.Ordered, V any](data map[K]V, sorter SortFunction[K, V]) *OrderedMap[K, V]
- func NewOrderedByValue[K constraints.Ordered, V OrderedValue](data map[K]V, sorter SortFunction[K, V]) *OrderedMap[K, V]
- func NewOrderedFromMap[K constraints.Ordered, V any](m *Map[K, V], sorter SortFunction[K, V]) *OrderedMap[K, V]
- func (m *OrderedMap[K, V]) Commit(fn func(data map[K]V))
- func (m *OrderedMap[K, V]) Delete(k K)
- func (m *OrderedMap[K, V]) Eventful(ctx context.Context, buf int) *EventfulMap[K, V]
- func (m *OrderedMap[K, V]) ForEach(fn func(k K, v V) error) error
- func (m *OrderedMap[K, V]) Iter() types.Iterator[K, V]
- func (m *OrderedMap[K, V]) Keys() (keys []K)
- func (m *OrderedMap[K, V]) ReadOnly() *ReadOnlyMap[K, V]
- func (m *OrderedMap[K, V]) Safe() *SafeMap[K, V]
- func (m *OrderedMap[K, V]) Set(k K, v V)
- func (m *OrderedMap[K, V]) UnmarshalCBOR(data []byte) error
- func (m *OrderedMap[K, V]) UnmarshalJSON(data []byte) error
- func (m *OrderedMap[K, V]) Values() (values []V)
- type OrderedValue
- type ReadOnlyMap
- func (ReadOnlyMap[K, V]) Commit(fn func(data map[K]V))
- func (ReadOnlyMap[K, V]) Delete(k K)
- func (ReadOnlyMap[K, V]) Set(k K, v V)
- func (ReadOnlyMap[K, V]) UnmarshalCBOR(data []byte) error
- func (ReadOnlyMap[K, V]) UnmarshalJSON(data []byte) error
- func (ReadOnlyMap[K, V]) UnmarshalText(data []byte) error
- type SafeMap
- func (m *SafeMap[K, V]) Commit(fn func(data map[K]V))
- func (m *SafeMap[K, V]) Copy() Maper[K, V]
- func (m *SafeMap[K, V]) Delete(k K)
- func (m *SafeMap[K, V]) Eventful(ctx context.Context, buf int) *EventfulMap[K, V]
- func (m *SafeMap[K, V]) Exists(k K) bool
- func (m *SafeMap[K, V]) ForEach(fn func(k K, v V) error) error
- func (m *SafeMap[K, V]) Get(k K) V
- func (m *SafeMap[K, V]) GetFull(k K) (obj V, exists bool)
- func (m *SafeMap[K, V]) Iter() types.Iterator[K, V]
- func (m *SafeMap[K, V]) Keys() (keys []K)
- func (m *SafeMap[K, V]) Len() int
- func (m *SafeMap[K, V]) MarshalCBOR() ([]byte, error)
- func (m *SafeMap[K, V]) MarshalJSON() ([]byte, error)
- func (m *SafeMap[K, V]) ReadOnly() *ReadOnlyMap[K, V]
- func (m *SafeMap[K, V]) Safe() *SafeMap[K, V]
- func (m *SafeMap[K, V]) Set(k K, v V)
- func (m *SafeMap[K, V]) String() string
- func (m *SafeMap[K, V]) UnmarshalCBOR(data []byte) error
- func (m *SafeMap[K, V]) UnmarshalJSON(data []byte) error
- func (m *SafeMap[K, V]) Values() (values []V)
- type SortFunction
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNilMap = errors.New("map is nil") ErrReadOnlyMap = errors.New("map is readonly") )
Functions ¶
func AnyElem ¶
func AnyElem[K comparable, V any, M ~map[K]V](m M) (K, V)
AnyElem returns first key and value found in map. If map is empty it returns default values. Multiple calls can return same or different values.
func Equals ¶
func Equals[K, V comparable, M ~map[K]V](a, b M) (equal bool)
Types ¶
type EventfulMap ¶
func NewEventful ¶
func NewEventful[K comparable, V any](m Maper[K, V], ctx context.Context, buf int) *EventfulMap[K, V]
func (*EventfulMap[K, V]) Delete ¶
func (m *EventfulMap[K, V]) Delete(k K)
func (*EventfulMap[K, V]) Set ¶
func (m *EventfulMap[K, V]) Set(k K, v V)
func (*EventfulMap[K, V]) UnmarshalCBOR ¶
func (m *EventfulMap[K, V]) UnmarshalCBOR(data []byte) error
func (*EventfulMap[K, V]) UnmarshalJSON ¶
func (m *EventfulMap[K, V]) UnmarshalJSON(data []byte) error
type EventfulMaper ¶
type Map ¶
type Map[K comparable, V any] struct { // 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]) Eventful ¶
func (m *Map[K, V]) Eventful(ctx context.Context, buf int) *EventfulMap[K, V]
func (*Map[K, V]) MarshalCBOR ¶
func (*Map[K, V]) MarshalJSON ¶
func (*Map[K, V]) Raw ¶
func (m *Map[K, V]) Raw() map[K]V
returns original map. Use copy before calling this method.
func (*Map[K, V]) UnmarshalCBOR ¶
func (*Map[K, V]) UnmarshalJSON ¶
type MapConverter ¶
type MapConverter[K comparable, V any] interface { // Eventful map forces safe Eventful(ctx context.Context, buf int) *EventfulMap[K, V] // return SafeMap Safe() *SafeMap[K, V] // return ReadOnly Map ReadOnly() *ReadOnlyMap[K, V] }
All maps must implement this interface themselves.
type Maper ¶
type Maper[K comparable, V any] interface { MapConverter[K, V] // return key existence Exists(k K) bool // return value for key Get(k K) V // return value and existence of key GetFull(k K) (obj V, exists bool) // set value for key Set(k K, v V) // delete key from Map Delete(k K) // run function with direct access to Map Commit(fn func(data map[K]V)) // return iterator for safe iterating over Map Iter() types.Iterator[K, V] // range over Map ForEach(fn func(k K, v V) error) error // return all Map keys Keys() (keys []K) // return all Map values Values() (values []V) // return Map length Len() int // return underlying Map copy (writable, non-safe or eventful) Copy() Maper[K, V] // returns original map. Use copy before calling this method. Raw() map[K]V MarshalJSON() ([]byte, error) UnmarshalJSON(data []byte) error MarshalCBOR() ([]byte, error) UnmarshalCBOR(data []byte) error String() string }
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, sorter SortFunction[K, V]) *OrderedMap[K, V]
func NewOrderedByValue ¶
func NewOrderedByValue[K constraints.Ordered, V OrderedValue](data map[K]V, sorter SortFunction[K, V]) *OrderedMap[K, V]
func NewOrderedFromMap ¶
func NewOrderedFromMap[K constraints.Ordered, V any](m *Map[K, V], sorter SortFunction[K, V]) *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]) Eventful ¶
func (m *OrderedMap[K, V]) Eventful(ctx context.Context, buf int) *EventfulMap[K, V]
func (*OrderedMap[K, V]) ForEach ¶
func (m *OrderedMap[K, V]) ForEach(fn func(k K, v V) error) error
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]) ReadOnly ¶
func (m *OrderedMap[K, V]) ReadOnly() *ReadOnlyMap[K, V]
func (*OrderedMap[K, V]) Safe ¶
func (m *OrderedMap[K, V]) Safe() *SafeMap[K, V]
func (*OrderedMap[K, V]) UnmarshalCBOR ¶
func (m *OrderedMap[K, V]) UnmarshalCBOR(data []byte) error
func (*OrderedMap[K, V]) UnmarshalJSON ¶
func (m *OrderedMap[K, V]) UnmarshalJSON(data []byte) error
func (*OrderedMap[K, V]) Values ¶
func (m *OrderedMap[K, V]) Values() (values []V)
return all Map values
type OrderedValue ¶
type ReadOnlyMap ¶
type ReadOnlyMap[K comparable, V any] struct { Maper[K, V] }
func NewReadOnlyMap ¶
func NewReadOnlyMap[K comparable, V any](m Maper[K, V]) *ReadOnlyMap[K, V]
func (ReadOnlyMap[K, V]) Commit ¶
func (ReadOnlyMap[K, V]) Commit(fn func(data map[K]V))
func (ReadOnlyMap[K, V]) Delete ¶
func (ReadOnlyMap[K, V]) Delete(k K)
func (ReadOnlyMap[K, V]) Set ¶
func (ReadOnlyMap[K, V]) Set(k K, v V)
func (ReadOnlyMap[K, V]) UnmarshalCBOR ¶
func (ReadOnlyMap[K, V]) UnmarshalCBOR(data []byte) error
func (ReadOnlyMap[K, V]) UnmarshalJSON ¶
func (ReadOnlyMap[K, V]) UnmarshalJSON(data []byte) error
func (ReadOnlyMap[K, V]) UnmarshalText ¶
func (ReadOnlyMap[K, V]) UnmarshalText(data []byte) error
type SafeMap ¶
type SafeMap[K comparable, V any] struct { Maper[K, V] // contains filtered or unexported fields }
func (*SafeMap[K, V]) Commit ¶
func (m *SafeMap[K, V]) Commit(fn func(data map[K]V))
run function with direct access to Map
func (*SafeMap[K, V]) Eventful ¶
func (m *SafeMap[K, V]) Eventful(ctx context.Context, buf int) *EventfulMap[K, V]
func (*SafeMap[K, V]) MarshalCBOR ¶
func (*SafeMap[K, V]) MarshalJSON ¶
func (*SafeMap[K, V]) ReadOnly ¶
func (m *SafeMap[K, V]) ReadOnly() *ReadOnlyMap[K, V]
return ReadOnly Map
func (*SafeMap[K, V]) UnmarshalCBOR ¶
func (*SafeMap[K, V]) UnmarshalJSON ¶
type SortFunction ¶
type SortFunction[K comparable, V any] func(data map[K]V) []types.Item[K, V]
Source Files ¶
Click to show internal directories.
Click to hide internal directories.