func (s *Set) Subset(condition func(string) bool) *Set {
	newSet := NewSet()
	s.Visit(func(v string) {
		if condition(v) {
			newSet.Add(v)
		}
	})
	return newSet
}
Subset builds a subset based on a conditional function.
package set
import (
	"fmt"
	"strings"
	hashtable "../hash-table"
)
type Set struct {
	items *hashtable.HashTable
}
func NewSet() *Set {
	return &Set{items: hashtable.NewHashTable()}
}
func (s *Set) Values() []string {
	var ret []string
	if s.IsEmpty() {
		return ret
	}
	for _, l := range s.items.Buckets {
		if l != nil {
			for cur := l.GetHead(); cur != nil; cur = cur.Next() {
				ret = append(ret, cur.GetKey())
			}
		}
	}
	return ret
}
func (s *Set) String() string {
	return fmt.Sprintf("[%s]", strings.Join(s.Values(), ","))
}
func (s *Set) Cardinality() uint64 {
	return s.items.NumEntries
}
func (s *Set) IsEmpty() bool {
	if s.Cardinality() == 0 {
		return true
	}
	return false
}
func (s *Set) Add(key string) {
	s.items.Put(key, true)
}
func (s *Set) Remove(key string) {
	s.items.Del(key)
}
func (s *Set) Contains(key string) bool {
	if s.items.Get(key) != nil {
		return true
	}
	return false
}
func (s *Set) Visit(fn func(string)) {
	for _, v := range s.Values() {
		fn(v)
	}
}