diff options
| author | Michael Anthony Knyszek <mknyszek@google.com> | 2024-08-13 16:33:30 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-11-18 20:35:28 +0000 |
| commit | 083045f99dde6fb00c4e8658a67cacce1e06825f (patch) | |
| tree | 1d16847252b45668bff9589c7d89aef4c7f80842 /src/internal | |
| parent | 107e094f51319f99f7353f1aeae36229deda34c0 (diff) | |
| download | go-083045f99dde6fb00c4e8658a67cacce1e06825f.tar.xz | |
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 <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/internal')
| -rw-r--r-- | src/internal/sync/hashtriemap.go | 5 |
1 files changed, 5 insertions, 0 deletions
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. // |
