Documentation
¶
Index ¶
- type AnyLeaf
- type BufferLeaf
- type Item
- func (i *Item[K, V]) Changed() bool
- func (i *Item[K, V]) Created() bool
- func (i *Item[K, V]) Defer(f func(V))
- func (i *Item[K, V]) Deleted() bool
- func (i *Item[K, V]) Key() K
- func (i1 *Item[K, V]) Less(i btree.Item) bool
- func (i *Item[K, V]) RunDeferred()
- func (i *Item[K, V]) Updated() bool
- func (i *Item[K, V]) Value() V
- type JSONLeaf
- type Leaf
- type Store
- func New[K constraints.Ordered, V Leaf](newValue func() V) *Store[K, V]
- func NewAnyStore[K constraints.Ordered, T any](equal func(a, b T) bool) *Store[K, *AnyLeaf[T]]
- func NewBufferStore[K constraints.Ordered]() *Store[K, *BufferLeaf]
- func NewJSONStore[K constraints.Ordered, T any]() *Store[K, *JSONLeaf[T]]
- func (s *Store[K, V]) Changed() (ret []*Item[K, V])
- func (s *Store[K, V]) Deleted() (ret []*Item[K, V])
- func (s *Store[K, V]) Done()
- func (s *Store[K, V]) Get(key K) V
- func (s *Store[K, V]) GetItem(key K) *Item[K, V]
- func (s *Store[K, V]) Has(key K) bool
- func (s *Store[K, V]) HasChanges() (changed bool)
- func (s *Store[K, V]) List() (ret []*Item[K, V])
- func (s *Store[K, V]) Reset()
- func (s *Store[K, V]) RunDeferred()
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyLeaf ¶
type AnyLeaf[T any] struct { // contains filtered or unexported fields }
func NewAnyLeaf ¶
type BufferLeaf ¶
Example ¶
bl := NewBufferLeaf() fmt.Fprintf(bl, "hello %d %.2f", 1, math.Pi) fmt.Println("[", bl, "]")
Output: [ hello 1 3.14 ]
func NewBufferLeaf ¶
func NewBufferLeaf() *BufferLeaf
func (*BufferLeaf) Hash ¶
func (l *BufferLeaf) Hash() uint64
func (*BufferLeaf) Reset ¶
func (l *BufferLeaf) Reset()
func (*BufferLeaf) Writeln ¶
func (l *BufferLeaf) Writeln()
type Item ¶
type Item[K constraints.Ordered, V Leaf] struct { // contains filtered or unexported fields }
func (*Item[K, V]) RunDeferred ¶
func (i *Item[K, V]) RunDeferred()
type JSONLeaf ¶
type JSONLeaf[T any] struct { // contains filtered or unexported fields }
func NewJSONLeaf ¶
type Store ¶
type Store[K constraints.Ordered, V Leaf] struct { // contains filtered or unexported fields }
Example ¶
store := NewBufferStore[string]() { fmt.Fprint(store.Get("a"), "hello a") store.Done() store.printDiff() } { store.Reset() fmt.Fprint(store.Get("a"), "hello a") store.Done() store.printDiff() } { store.Reset() fmt.Fprint(store.Get("a"), "hello a") fmt.Fprint(store.Get("b"), "hello b") store.Done() store.printDiff() } { store.Reset() fmt.Fprint(store.Get("a"), "hi a") store.Done() store.printDiff() } { store.Reset() fmt.Fprint(store.Get("b"), "hi b") store.Done() store.printDiff() } { store.Reset() store.Done() store.printDiff() }
Output: ----- C a => "hello a" ----- <same> ----- C b => "hello b" ----- U a => "hi a" D b ----- C b => "hi b" D a ----- D b
func NewAnyStore ¶
func NewBufferStore ¶
func NewBufferStore[K constraints.Ordered]() *Store[K, *BufferLeaf]
func NewJSONStore ¶
func NewJSONStore[K constraints.Ordered, T any]() *Store[K, *JSONLeaf[T]]
func (*Store[K, V]) Done ¶
func (s *Store[K, V]) Done()
Done must be called at the end of the filling process. It will compute hashes of every node to allow diff functions to work.
func (*Store[K, V]) HasChanges ¶
func (*Store[K, V]) RunDeferred ¶
func (s *Store[K, V]) RunDeferred()
Click to show internal directories.
Click to hide internal directories.