Documentation
¶
Overview ¶
Package ctrie provides an implementation of the Map data structure, which is a concurrent, lock-free hash trie. This data structure was originally presented in the paper Concurrent Tries with Efficient Non-Blocking Clones:
Index ¶
- func BytesHash(key []byte) uint64
- func StringHash(key string) uint64
- type Hasher
- type Iter
- type Map
- func (c *Map[Key, Value]) Clear()
- func (c *Map[Key, Value]) Clone() *Map[Key, Value]
- func (c *Map[Key, Value]) Delete(key Key) (Value, bool)
- func (c *Map[Key, Value]) Get(key Key) (Value, bool)
- func (c *Map[Key, Value]) Iterator() *Iter[Key, Value]
- func (c *Map[Key, Value]) Len() int
- func (c *Map[Key, Value]) RClone() *Map[Key, Value]
- func (c *Map[Key, Value]) Set(key Key, value Value)
- type String
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringHash ¶
Types ¶
type Hasher ¶
type Hasher interface { comparable Hash() uint64 }
type Iter ¶
type Iter[Key, Value any] struct { // contains filtered or unexported fields }
Iter is an iterator that iterates through entries in the map.
type Map ¶
type Map[Key, Value any] struct { // contains filtered or unexported fields }
Map implements a map that can be updated concurrently and also has a low cost snapshot operation.
func NewWithFuncs ¶
func NewWithFuncs[Key, Value any]( eqFunc func(k1, k2 Key) bool, hashFunc func(Key) uint64, ) *Map[Key, Value]
NewWithFuncs is like New except that it uses explicit functions for comparison and hashing instead of relying on comparison and hashing on the value itself.
func (*Map[Key, Value]) Clear ¶
func (c *Map[Key, Value]) Clear()
Clear removes all keys from the Map.
func (*Map[Key, Value]) Clone ¶
Clone returns a stable, point-in-time clone of the Map. If the Map is read-only, the returned Map will also be read-only.
func (*Map[Key, Value]) Delete ¶
Delete deletes the value for the associated key, returning the deleted value and returning true if an entry was removed.
func (*Map[Key, Value]) Get ¶
Get returns the value for the associated key and reports whether the key exists in the trie.