introduce WithRootNodesAndDown to walk the graph from specified nodes and down

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof
2023-05-12 10:42:03 +02:00
committed by Nicolas De loof
parent 93bd27a0cc
commit ca19b7fcc9
4 changed files with 174 additions and 11 deletions

View File

@@ -20,8 +20,18 @@ func (s Set[T]) Add(v T) {
s[v] = struct{}{}
}
func (s Set[T]) Remove(v T) {
delete(s, v)
func (s Set[T]) AddAll(v ...T) {
for _, e := range v {
s[e] = struct{}{}
}
}
func (s Set[T]) Remove(v T) bool {
_, ok := s[v]
if ok {
delete(s, v)
}
return ok
}
func (s Set[T]) Clear() {