util/set: add some useful utility functions for Set (#9535)

Also give each type of set its own file.

Updates #cleanup

Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
This commit is contained in:
Chris Palmer
2023-09-29 14:31:02 -07:00
committed by GitHub
parent 0c8c374a41
commit 8833dc51f1
4 changed files with 94 additions and 26 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ type Slice[T comparable] struct {
set map[T]bool // nil until/unless slice is large enough
}
// Slice returns the a view of the underlying slice.
// Slice returns a view of the underlying slice.
// The elements are in order of insertion.
// The returned value is only valid until ss is modified again.
func (ss *Slice[T]) Slice() views.Slice[T] { return views.SliceOf(ss.slice) }