diff --git a/backend/idset.go b/backend/idset.go index 25543d8dd..4f27f3489 100644 --- a/backend/idset.go +++ b/backend/idset.go @@ -28,3 +28,22 @@ func (s IDSet) Insert(id ID) { func (s IDSet) Delete(id ID) { delete(s, id) } + +// List returns a slice of all IDs in the set. +func (s IDSet) List() IDs { + list := make(IDs, 0, len(s)) + for id := range s { + list = append(list, id) + } + + return list +} + +func (s IDSet) String() string { + str := s.List().String() + if len(str) < 2 { + return "{}" + } + + return "{" + str[1:len(str)-2] + "}" +}