Documentation
¶
Index ¶
- func RegisterKeyType[K any](bytesFromKey func(K) []byte)
- func RootOnlyWatch(o *options)
- type Iterator
- type Map
- func (m Map[K, V]) All() iter.Seq2[K, V]
- func (m Map[K, V]) Delete(key K) Map[K, V]
- func (m Map[K, V]) EqualKeys(other Map[K, V]) bool
- func (m Map[K, V]) Get(key K) (value V, found bool)
- func (m Map[K, V]) Len() int
- func (m Map[K, V]) LowerBound(from K) iter.Seq2[K, V]
- func (m Map[K, V]) MarshalJSON() ([]byte, error)
- func (m Map[K, V]) MarshalYAML() (any, error)
- func (m Map[K, V]) Prefix(prefix K) iter.Seq2[K, V]
- func (m Map[K, V]) Set(key K, value V) Map[K, V]
- func (m Map[K, V]) SlowEqual(other Map[K, V]) bool
- func (m *Map[K, V]) UnmarshalJSON(data []byte) error
- func (m *Map[K, V]) UnmarshalYAML(value *yaml.Node) error
- type Ops
- type Option
- type Set
- func (s Set[T]) All() iter.Seq[T]
- func (s Set[T]) Delete(v T) Set[T]
- func (s Set[T]) Difference(s2 Set[T]) Set[T]
- func (s Set[T]) Equal(other Set[T]) bool
- func (s Set[T]) Has(v T) bool
- func (s Set[T]) Len() int
- func (s Set[T]) MarshalJSON() ([]byte, error)
- func (s Set[T]) MarshalYAML() (any, error)
- func (s Set[T]) Set(v T) Set[T]
- func (s Set[T]) ToBytesFunc() func(T) []byte
- func (s Set[T]) Union(s2 Set[T]) Set[T]
- func (s *Set[T]) UnmarshalJSON(data []byte) error
- func (s *Set[T]) UnmarshalYAML(value *yaml.Node) error
- type Tree
- func (t *Tree[T]) Delete(key []byte) (old T, hadOld bool, tree *Tree[T])
- func (t *Tree[T]) Get(key []byte) (T, <-chan struct{}, bool)
- func (t *Tree[T]) Insert(key []byte, value T) (old T, hadOld bool, tree *Tree[T])
- func (t *Tree[T]) Iterator() *Iterator[T]
- func (t *Tree[T]) Len() int
- func (t *Tree[T]) LowerBound(key []byte) *Iterator[T]
- func (t *Tree[T]) Modify(key []byte, mod func(T) T) (old T, hadOld bool, tree *Tree[T])
- func (t *Tree[T]) Prefix(prefix []byte) (*Iterator[T], <-chan struct{})
- func (t *Tree[T]) PrintTree()
- func (t *Tree[T]) RootWatch() <-chan struct{}
- func (t *Tree[T]) Txn() *Txn[T]
- type Txn
- func (txn *Txn[T]) Clone() *Txn[T]
- func (txn *Txn[T]) Commit() *Tree[T]
- func (txn *Txn[T]) CommitOnly() *Tree[T]
- func (txn *Txn[T]) Delete(key []byte) (old T, hadOld bool)
- func (txn *Txn[T]) Get(key []byte) (T, <-chan struct{}, bool)
- func (txn *Txn[T]) Insert(key []byte, value T) (old T, hadOld bool)
- func (txn *Txn[T]) InsertWatch(key []byte, value T) (old T, hadOld bool, watch <-chan struct{})
- func (txn *Txn[T]) Iterator() *Iterator[T]
- func (txn *Txn[T]) Len() int
- func (txn *Txn[T]) LowerBound(key []byte) *Iterator[T]
- func (txn *Txn[T]) Modify(key []byte, mod func(T) T) (old T, hadOld bool)
- func (txn *Txn[T]) ModifyWatch(key []byte, mod func(T) T) (old T, hadOld bool, watch <-chan struct{})
- func (txn *Txn[T]) Notify()
- func (txn *Txn[T]) Prefix(key []byte) (*Iterator[T], <-chan struct{})
- func (txn *Txn[T]) PrintTree()
- func (txn *Txn[T]) RootWatch() <-chan struct{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterKeyType ¶
RegisterKeyType registers a new key type to be used with the Map and Set types. Intended to be called from init() functions. For Set-only usage only the [bytesFromKey] function is needed.
func RootOnlyWatch ¶
func RootOnlyWatch(o *options)
RootOnlyWatch sets the tree to only have a watch channel on the root node. This improves the speed at the cost of having a much more coarse grained notifications.
Types ¶
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator for key and value pairs where value is of type T
type Map ¶
type Map[K, V any] struct { // contains filtered or unexported fields }
Map of key-value pairs. The zero value is ready for use, provided that the key type has been registered with RegisterKeyType.
Map is a typed wrapper around Tree[T] for working with keys that are not []byte.
func FromMap ¶
func FromMap[K comparable, V any](m Map[K, V], hm map[K]V) Map[K, V]
FromMap copies values from the hash map into the given Map. This is not implemented as a method on Map[K,V] as hash maps require the comparable constraint and we do not need to limit Map[K, V] to that.
func (Map[K, V]) All ¶
All iterates every key-value in the map in order. The order is in bytewise order of the byte slice returned by bytesFromKey.
func (Map[K, V]) Delete ¶
Delete a value from the map. Returns a new map without the element pointed to by the key (if found).
func (Map[K, V]) LowerBound ¶
LowerBound iterates over all keys in order with value equal to or greater than [from].