]> Cypherpunks repositories - gostls13.git/commitdiff
internal/sync: add Delete to HashTrieMap
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 13 Aug 2024 16:33:30 +0000 (16:33 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 18 Nov 2024 20:35:28 +0000 (20:35 +0000)
This change adds the Delete operation (with the same semantics as
sync.Map's Delete) to HashTrieMap.

Change-Id: If90376ff735256444538719d670ed07e9e42870b
Reviewed-on: https://go-review.googlesource.com/c/go/+/606458
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>

src/internal/sync/hashtriemap.go

index 5862962e9b0b061dcb23bfbb505386b9fef5821b..4a7ae07166f4d4e2554db97fe78e57d384a334e8 100644 (file)
@@ -355,6 +355,11 @@ func (ht *HashTrieMap[K, V]) LoadAndDelete(key K) (value V, loaded bool) {
        return v, true
 }
 
+// Delete deletes the value for a key.
+func (ht *HashTrieMap[K, V]) Delete(key K) {
+       _, _ = ht.LoadAndDelete(key)
+}
+
 // CompareAndDelete deletes the entry for key if its value is equal to old.
 // The value type must be comparable, otherwise this CompareAndDelete will panic.
 //