Commit cdef63fb authored by Jeromy's avatar Jeromy

add 'Prefix' object and some more helper routines

parent 35c32d52
...@@ -26,7 +26,7 @@ func (s *Set) Len() int { ...@@ -26,7 +26,7 @@ func (s *Set) Len() int {
} }
func (s *Set) Keys() []*Cid { func (s *Set) Keys() []*Cid {
var out []*Cid out := make([]*Cid, 0, len(s.set))
for k, _ := range s.set { for k, _ := range s.set {
c, _ := Cast([]byte(k)) c, _ := Cast([]byte(k))
out = append(out, c) out = append(out, c)
...@@ -42,3 +42,14 @@ func (s *Set) Visit(c *Cid) bool { ...@@ -42,3 +42,14 @@ func (s *Set) Visit(c *Cid) bool {
return false return false
} }
func (s *Set) ForEach(f func(c *Cid) error) error {
for cs, _ := range s.set {
c, _ := Cast([]byte(cs))
err := f(c)
if err != nil {
return err
}
}
return nil
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment