func (s *set) Deflate() {
	s.values = make(map[interface{}]struct{})
}
Deflate implements the Set interface.
package collections
import (
	"fmt"
	"github.com/tideland/golib/errors"
)
type set struct {
	values map[interface{}]struct{}
}
func NewSet(vs ...interface{}) Set {
	s := &set{make(map[interface{}]struct{})}
	s.Add(vs...)
	return s
}
func (s *set) Add(vs ...interface{}) {
	for _, v := range vs {
		s.values[v] = struct{}{}
	}
}
func (s *set) Remove(vs ...interface{}) {
	for _, v := range vs {
		delete(s.values, v)
	}
}
func (s *set) Contains(v interface{}) bool {
	_, ok := s.values[v]
	return ok
}
func (s *set) All() []interface{} {
	all := []interface{}{}
	for v := range s.values {
		all = append(all, v)
	}
	return all
}
func (s *set) FindAll(f func(v interface{}) (bool, error)) ([]interface{}, error) {
	found := []interface{}{}
	for v := range s.values {
		ok, err := f(v)
		if err != nil {
			return nil, errors.Annotate(err, ErrFindAll, errorMessages)
		}
		if ok {
			found = append(found, v)
		}
	}
	return found, nil
}
func (s *set) DoAll(f func(v interface{}) error) error {
	for v := range s.values {
		if err := f(v); err != nil {
			return errors.Annotate(err, ErrDoAll, errorMessages)
		}
	}
	return nil
}
func (s *set) Len() int {
	return len(s.values)
}