summaryrefslogtreecommitdiffhomepage
path: root/util/set
AgeCommit message (Collapse)AuthorFilesLines
2025-10-02control/controlclient: restore aggressive Direct.Close teardownBrad Fitzpatrick1-4/+12
In the earlier http2 package migration (1d93bdce20ddd2, #17394) I had removed Direct.Close's tracking of the connPool, thinking it wasn't necessary. Some tests (in another repo) are strict and like it to tear down the world and wait, to check for leaked goroutines. And they caught this letting some goroutines idle past Close, even if they'd eventually close down on their own. This restores the connPool accounting and the aggressife close. Updates #17305 Updates #17394 Change-Id: I5fed283a179ff7c3e2be104836bbe58b05130cc7 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-07-30util/set: add more functionality to IntSet (#16640)Joe Tsai2-0/+32
2025-07-22util/set: add IntSet (#16602)Joe Tsai2-0/+346
IntSet is a set optimized for integers. Updates tailscale/corp#29809 Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2025-05-29util/set: add SmallSet.SoleElement, fix bug, add more testsBrad Fitzpatrick2-5/+54
This adds SmallSet.SoleElement, which I need in another repo for efficiency. I added tests, but those tests failed because Add(1) + Add(1) was promoting the first Add's sole element to a map of one item. So fix that, and add more tests. Updates tailscale/corp#29093 Change-Id: Iadd5ad08afe39721ee5449343095e389214d8389 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-29util/set: add SmallSetBrad Fitzpatrick2-0/+225
Updates tailscale/corp#29093 Change-Id: I0e07e83dee51b4915597a913b0583c99756d90e2 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-11-11all: use iterators over slice views moreBrad Fitzpatrick1-2/+2
This gets close to all of the remaining ones. Updates #12912 Change-Id: I9c672bbed2654a6c5cab31e0cbece6c107d8c6fa Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-05-05util/set: add Of variant of SetOf that takes variadic parameterBrad Fitzpatrick2-10/+31
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>
2024-04-16all: use Go 1.22 range-over-intBrad Fitzpatrick1-1/+1
Updates #11058 Change-Id: I35e7ef9b90e83cac04ca93fd964ad00ed5b48430 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-11-20util/set: implement json.Marshaler/Unmarshaler (#10308)Andrew Lytvynov2-0/+60
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 Palmer2-2/+2
Updates #cleanup Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
2023-10-31util/set: add some more Set operations (#10022)Chris Palmer2-3/+74
Updates #cleanup Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
2023-09-29util/set: add some useful utility functions for Set (#9535)Chris Palmer4-26/+94
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-08-30cmd/k8s-operator: add metrics to track usageMaisem Ali1-0/+3
Updates #502 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-08-17all: use Go 1.21 slices, maps instead of x/exp/{slices,maps}Brad Fitzpatrick1-1/+2
Updates #8419 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-05-11util/set: add a basic map-based Set typeBrad Fitzpatrick2-0/+39
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-04-14util/set: move Slice type from corp to ossAndrew Dunham2-0/+125
This is an exact copy of the files misc/set/set{,_test}.go from tailscale/corp@a5415daa9ca80ce9b798cd80148e4bc8818f8e15, plus the license headers. For use in #7877 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: I712d09c6d1a180c6633abe3acf8feb59b27e2866
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>