Package-Level Type Names (total 6, in which 1 is exported)
/* sort exporteds by: | */
Type Parameters:
K: comparable
V: comparable HashTrieMap is an implementation of a concurrent hash-trie. The implementation
is designed around frequent loads, but offers decent performance for stores
and deletes as well, especially if the map is larger. It's primary use-case is
the unique package, but can be used elsewhere as well.keyEqualequalFunckeyHashhashFuncroot*indirect[K, V]seeduintptrvalEqualequalFunc All returns an iter.Seq2 that produces all key-value pairs in the map.
The enumeration does not represent any consistent snapshot of the map,
but is guaranteed to visit each unique key-value pair only once. It is
safe to operate on the tree during iteration. No particular enumeration
order is guaranteed. CompareAndDelete deletes the entry for key if its value is equal to old.
If there is no current value for key in the map, CompareAndDelete returns false
(even if the old value is the nil interface value). Load returns the value stored in the map for a key, or nil if no
value is present.
The ok result indicates whether value was found in the map. LoadOrStore returns the existing value for the key if present.
Otherwise, it stores and returns the given value.
The loaded result is true if the value was loaded, false if stored. expand takes oldEntry and newEntry whose hashes conflict from bit 64 down to hashShift and
produces a subtree of indirect nodes to hold the two new entries.(*HashTrieMap[K, V]) iter(i *indirect[K, V], yield func(key K, value V) bool) bool
func NewHashTrieMap[K, V]() *HashTrieMap[K, V]
var unique.uniqueMaps *concurrent.HashTrieMap[...]
Type Parameters:
K: comparable
V: comparable entry is a leaf node in the hash-trie.keyKnodenode[K, V]node.isEntrybool // Overflow for hash collisions.valueV compareAndDelete deletes an entry in the overflow chain if both the key and value compare
equal. Returns the new entry chain and whether or not anything was deleted.
compareAndDelete must be called under the mutex of the indirect node which e is a child of.(*entry[K, V]) entry() *entry[K, V](*entry[K, V]) indirect() *indirect[K, V](*entry[K, V]) lookup(key K, equal equalFunc) (V, bool)
func newEntryNode[K, V](key K, value V) *entry[K, V]
func (*HashTrieMap)[K, V].expand(oldEntry, newEntry *entry[K, V], newHash uintptr, hashShift uint, parent *indirect[K, V]) *node[K, V]
16 children. This seems to be the sweet spot for
load performance: any smaller and we lose out on
50% or more in CPU performance. Any larger and the
returns are minuscule (~1% improvement for 32 children).
The pages are generated with Goldsv0.7.6. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.