summaryrefslogtreecommitdiff
path: root/lib/containers
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-08-30 00:30:21 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-08-30 21:29:22 -0600
commit6543bbc9ffeaa2ba28b4d1ba5d6db509213b5e5d (patch)
tree614eaebbbe9b5ffa29f4373c677a0800bb78a303 /lib/containers
parent5411e6b88bdccff020c4de25c065a0ba4710589c (diff)
wip
Diffstat (limited to 'lib/containers')
-rw-r--r--lib/containers/set.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/containers/set.go b/lib/containers/set.go
index e20b5be..4e40894 100644
--- a/lib/containers/set.go
+++ b/lib/containers/set.go
@@ -46,14 +46,23 @@ func (o *Set[T]) DecodeJSON(r io.RuneScanner) error {
}
func (o *Set[T]) Insert(v T) {
- if o == nil {
+ if *o == nil {
*o = Set[T]{}
}
(*o)[v] = struct{}{}
}
+func (o *Set[T]) InsertFrom(p Set[T]) {
+ if *o == nil {
+ *o = Set[T]{}
+ }
+ for v := range p {
+ (*o)[v] = struct{}{}
+ }
+}
+
func (o *Set[T]) Delete(v T) {
- if o == nil {
+ if *o == nil {
return
}
delete(*o, v)