1
0
mirror of https://github.com/restic/restic.git synced 2024-06-26 07:49:01 +02:00

Add methods to IDSet

This commit is contained in:
Alexander Neumann 2015-08-16 16:07:51 +02:00
parent d42ff509ba
commit 5c46dc41de

View File

@ -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] + "}"
}