summaryrefslogtreecommitdiffhomepage
path: root/util/set/set.go
AgeCommit message (Collapse)AuthorFilesLines
2024-05-05util/set: add Of variant of SetOf that takes variadic parameterBrad Fitzpatrick1-0/+12
set.Of(1, 2, 3) is prettier than set.SetOf([]int{1, 2, 3}). I was going to change the signature of SetOf but then I noticed its name has stutter anyway, so I kept it for compatibility. People can prefer to use set.Of for new code or slowly migrate. Also add a lazy Make method, which I often find myself wanting, without having to resort to uglier mak.Set(&set, k, struct{}{}). Updates #cleanup Change-Id: Ic6f3870115334efcbd65e79c437de2ad3edb7625 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-11-20util/set: implement json.Marshaler/Unmarshaler (#10308)Andrew Lytvynov1-0/+14
Marshal as a JSON list instead of a map. Because set elements are `comparable` and not `cmp.Ordered`, we cannot easily sort the items before marshaling. Updates #cleanup Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2023-11-01util/set: make Clone a method (#10044)Chris Palmer1-1/+1
Updates #cleanup Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
2023-10-31util/set: add some more Set operations (#10022)Chris Palmer1-2/+23
Updates #cleanup Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
2023-09-29util/set: add some useful utility functions for Set (#9535)Chris Palmer1-24/+24
Also give each type of set its own file. Updates #cleanup Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
2023-09-09all: use set.Set consistently instead of map[T]struct{}Brad Fitzpatrick1-0/+3
I didn't clean up the more idiomatic map[T]bool with true values, at least yet. I just converted the relatively awkward struct{}-valued maps. Updates #cleanup Change-Id: I758abebd2bb1f64bc7a9d0f25c32298f4679c14f Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-05-11util/set: add a basic map-based Set typeBrad Fitzpatrick1-0/+15
We have two other types of Sets here. Add the basic obvious one too. Needed for a change elsewhere. Updates #cleanup Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-01-27all: update copyright and license headersWill Norris1-3/+2
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
2022-11-28util/set: add new set package for SetHandle typeBrad Fitzpatrick1-0/+30
We use this pattern in a number of places (in this repo and elsewhere) and I was about to add a fourth to this repo which was crossing the line. Add this type instead so they're all the same. Also, we have another Set type (SliceSet, which tracks its keys in order) in another repo we can move to this package later. Change-Id: Ibbdcdba5443fae9b6956f63990bdb9e9443cefa9 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>