Update
This commit is contained in:
16
vendor/tailscale.com/util/set/handle.go
generated
vendored
16
vendor/tailscale.com/util/set/handle.go
generated
vendored
@@ -9,20 +9,28 @@ package set
|
||||
type HandleSet[T any] map[Handle]T
|
||||
|
||||
// Handle is an opaque comparable value that's used as the map key in a
|
||||
// HandleSet. The only way to get one is to call HandleSet.Add.
|
||||
// HandleSet.
|
||||
type Handle struct {
|
||||
v *byte
|
||||
}
|
||||
|
||||
// NewHandle returns a new handle value.
|
||||
func NewHandle() Handle {
|
||||
return Handle{new(byte)}
|
||||
}
|
||||
|
||||
// Add adds the element (map value) e to the set.
|
||||
//
|
||||
// It returns the handle (map key) with which e can be removed, using a map
|
||||
// delete.
|
||||
// It returns a new handle (map key) with which e can be removed, using a map
|
||||
// delete or the [HandleSet.Delete] method.
|
||||
func (s *HandleSet[T]) Add(e T) Handle {
|
||||
h := Handle{new(byte)}
|
||||
h := NewHandle()
|
||||
if *s == nil {
|
||||
*s = make(HandleSet[T])
|
||||
}
|
||||
(*s)[h] = e
|
||||
return h
|
||||
}
|
||||
|
||||
// Delete removes the element with handle h from the set.
|
||||
func (s HandleSet[T]) Delete(h Handle) { delete(s, h) }
|
||||
|
||||
Reference in New Issue
Block a user