Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
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() 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 := immap.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. Get(key K) (V, bool) // Contains returns true if a key exists. Contains(key K) bool // Iterator returns an iterator. Iterator() Iterator[K, V] // Keys returns all keys. Keys() []K // Set adds an item to the map. Set(key K, value V) // Move moves an item from one key to another, or returns false if the key does not exist. Move(key K, newKey K) bool // Delete deletes an item by a key. Delete(key K) // Free frees the map. Free() }
Map is an immutable sorted map, implemented as a btree.
Click to show internal directories.
Click to hide internal directories.