Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CompareFunc ¶
CompareFunc compares two keys, and returns -1 if a < b, 0 if a == b, 1 if a > b.
type Iterator ¶
type Iterator[K any, V any] interface { // OK returns true when the iterator points to a valid item, or false on end. OK() bool // Key returns the current key or zero, the key is valid until the next iteration. Key() K // Value returns the current value or zero, the value is valid until the next iteration. Value() ref.R[V] // Next moves to the next item. Next() bool // Previous moves to the previous item. Previous() bool // SeekToStart positions the iterator at the start. SeekToStart() bool // SeekToEnd positions the iterator at the end. SeekToEnd() bool // SeekBefore positions the iterator before an item with key >= key. SeekBefore(key K) bool // Free frees the iterator, implements the ref.Free interface. Free() }
Iterator sequentially iterates over sorted map items.
Usage:
it := refmap.Iterator() defer it.Free() it.SeekToStart() for it.Next() { key := it.Key() value := it.Value() }
type Map ¶
type Map[K, V any] interface { // Empty returns true if the map is empty. Empty() bool // Length returns the number of items in this map, this can be an estimate. Length() int64 // Mutable returns true if the map is mutable. Mutable() bool // Clone returns a mutable clone of the map. Clone() Map[K, V] // Freeze makes the map immutable. Freeze() // Get returns an item by a key, does not retain the value. Get(key K) (ref.R[V], bool) // Contains returns true if the map contains a key. Contains(key K) bool // Iterator returns an iterator, the iterator does not retain the values. Iterator() Iterator[K, V] // Keys returns all keys. Keys() []K // Set adds an item to the map, wraps into into a reference. Set(key K, value V) // SetRetain adds an item reference to the map, and retains it. SetRetain(key K, value ref.R[V]) // Delete deletes an item by a key, releases its value. Delete(key K) // Free frees the map, releases all values. Free() }
Map is an immutable sorted map which stores countable references, implemented as a btree.
The map retains/releases references internally, but does not retain them when iterating or returning.
Click to show internal directories.
Click to hide internal directories.