summaryrefslogtreecommitdiff
path: root/lib/containers/set.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/containers/set.go')
-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)