From 083045f99dde6fb00c4e8658a67cacce1e06825f Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Tue, 13 Aug 2024 16:33:30 +0000 Subject: [PATCH] internal/sync: add Delete to HashTrieMap 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 LUCI-TryBot-Result: Go LUCI Auto-Submit: Michael Knyszek --- src/internal/sync/hashtriemap.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/internal/sync/hashtriemap.go b/src/internal/sync/hashtriemap.go index 5862962e9b..4a7ae07166 100644 --- a/src/internal/sync/hashtriemap.go +++ b/src/internal/sync/hashtriemap.go @@ -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. // -- 2.48.1