This change adds the Store operation (with the same semantics as
sync.Map's Store) to HashTrieMap.
Change-Id: Ida55421f28d8cc6527f983f7f1c2fd55bb280925
Reviewed-on: https://go-review.googlesource.com/c/go/+/606455
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
return &top.node
}
+// Store sets the value for a key.
+func (ht *HashTrieMap[K, V]) Store(key K, old V) {
+ _, _ = ht.Swap(key, old)
+}
+
// Swap swaps the value for a key and returns the previous value if any.
// The loaded result reports whether the key was present.
func (ht *HashTrieMap[K, V]) Swap(key K, new V) (previous V, loaded bool) {