tag : break apart into smaller files of related function

This commit is contained in:
bth 2026-01-20 14:46:04 -08:00
commit bab61c31a3
6 changed files with 431 additions and 399 deletions

37
tag/set.go Normal file
View file

@ -0,0 +1,37 @@
package tag
import (
"maps"
"slices"
)
// convenience shorthand for this awkward map type.
type Set map[string]bool
// add members to the "set"
func (s Set) Add(mems ...string) {
for _, m := range mems {
s[m] = true
}
}
// get all members in a slice
func (s Set) Members() []string {
return slices.Collect(maps.Keys(s))
}
// s ∪ t
func (s Set) Union(tt ...Set) {
for _, t := range tt {
s.Add(t.Members()...)
}
}
// s ∩ t
func (s Set) Intersect(t Set) {
for m, _ := range s {
if !t[m] {
delete(s, m)
}
}
}