Documentation ¶
Overview ¶
Package treeset implements a Tree backed by a red-black Tree.
Structure is not thread safe.
Reference: http://en.wikipedia.org/wiki/Set_%28abstract_data_type%29
Package treeset implements a Tree backed by a red-black Tree.
Structure is not thread safe.
Reference: http://en.wikipedia.org/wiki/Set_%28abstract_data_type%29
Index ¶
- Variables
- func MultiStringSetIntersection(a *MultiStringSet, b *MultiStringSet, callback func(elem string))
- func StringSetIntersection(a *StringSet, b *StringSet, callback func(elem string))
- type IteratorMultiStringSet
- type IteratorStringSet
- type MultiStringSet
- func (set *MultiStringSet) Add(items ...string)
- func (set *MultiStringSet) AddItem(item string) (bool, string)
- func (set *MultiStringSet) Begin() IteratorMultiStringSet
- func (set *MultiStringSet) Contains(items ...string) bool
- func (set *MultiStringSet) Each(f func(value string))
- func (set *MultiStringSet) End() IteratorMultiStringSet
- func (set *MultiStringSet) Find(f func(value string) bool) (v string)
- func (set *MultiStringSet) Iterator() IteratorMultiStringSet
- func (set *MultiStringSet) LowerBound(item string) IteratorMultiStringSet
- func (set MultiStringSet) MarshalJSON() ([]byte, error)
- func (set MultiStringSet) Pack() (re []byte, err error)
- func (set *MultiStringSet) Remove(items ...string)
- func (set *MultiStringSet) String() string
- func (set *MultiStringSet) UnmarshalJSON(data []byte) error
- func (set *MultiStringSet) Unpack(in []byte) (int, error)
- func (set *MultiStringSet) UpperBound(item string) IteratorMultiStringSet
- func (set *MultiStringSet) Values() []string
- type StringSet
- func (set *StringSet) Add(items ...string)
- func (set *StringSet) AddItem(item string) (bool, string)
- func (set *StringSet) Begin() IteratorStringSet
- func (set *StringSet) Contains(items ...string) bool
- func (set *StringSet) Each(f func(value string))
- func (set *StringSet) End() IteratorStringSet
- func (set *StringSet) Find(f func(value string) bool) (v string)
- func (set *StringSet) Iterator() IteratorStringSet
- func (set *StringSet) LowerBound(item string) IteratorStringSet
- func (set StringSet) MarshalJSON() ([]byte, error)
- func (set StringSet) Pack() (re []byte, err error)
- func (set *StringSet) Remove(items ...string)
- func (set *StringSet) String() string
- func (set *StringSet) UnmarshalJSON(data []byte) error
- func (set *StringSet) Unpack(in []byte) (int, error)
- func (set *StringSet) UpperBound(item string) IteratorStringSet
- func (set *StringSet) Values() []string
Constants ¶
This section is empty.
Variables ¶
var StringComparator = func(a, b interface{}) int { return container.StringComparator(a.(string), b.(string)) }
Functions ¶
func MultiStringSetIntersection ¶
func MultiStringSetIntersection(a *MultiStringSet, b *MultiStringSet, callback func(elem string))
func StringSetIntersection ¶
Types ¶
type IteratorMultiStringSet ¶
Iterator returns a stateful iterator whose values can be fetched by an index.
func (IteratorMultiStringSet) Value ¶
func (iterator IteratorMultiStringSet) Value() string
Value returns the current element's value. Does not modify the state of the iterator.
type IteratorStringSet ¶
Iterator returns a stateful iterator whose values can be fetched by an index.
func (IteratorStringSet) Value ¶
func (iterator IteratorStringSet) Value() string
Value returns the current element's value. Does not modify the state of the iterator.
type MultiStringSet ¶
Set holds elements in a red-black Tree
func CopyFromMultiStringSet ¶
func CopyFromMultiStringSet(ts *MultiStringSet) *MultiStringSet
func NewMultiStringSet ¶
func NewMultiStringSet(Value ...string) *MultiStringSet
func (*MultiStringSet) Add ¶
func (set *MultiStringSet) Add(items ...string)
Add adds the items (one or more) to the set.
func (*MultiStringSet) AddItem ¶
func (set *MultiStringSet) AddItem(item string) (bool, string)
Add adds the item one to the set.Returns false and the interface if it already exists
func (*MultiStringSet) Begin ¶
func (set *MultiStringSet) Begin() IteratorMultiStringSet
Begin returns First Iterator whose position points to the first element Return End Iterator when the map is empty
func (*MultiStringSet) Contains ¶
func (set *MultiStringSet) Contains(items ...string) bool
Contains checks weather items (one or more) are present in the set. All items have to be present in the set for the method to return true. Returns true if no arguments are passed at all, i.e. set is always superset of empty set.
func (*MultiStringSet) Each ¶
func (set *MultiStringSet) Each(f func(value string))
Each calls the given function once for each element, passing that element's index and value.
func (*MultiStringSet) End ¶
func (set *MultiStringSet) End() IteratorMultiStringSet
End returns End Iterator
func (*MultiStringSet) Find ¶
func (set *MultiStringSet) Find(f func(value string) bool) (v string)
Find passes each element of the container to the given function and returns the first (index,value) for which the function is true or -1,nil otherwise if no element matches the criteria.
func (*MultiStringSet) Iterator ¶
func (set *MultiStringSet) Iterator() IteratorMultiStringSet
Iterator holding the iterator's state
func (*MultiStringSet) LowerBound ¶
func (set *MultiStringSet) LowerBound(item string) IteratorMultiStringSet
func (MultiStringSet) MarshalJSON ¶
func (set MultiStringSet) MarshalJSON() ([]byte, error)
ToJSON outputs the JSON representation of the set.
func (MultiStringSet) Pack ¶
func (set MultiStringSet) Pack() (re []byte, err error)
func (*MultiStringSet) Remove ¶
func (set *MultiStringSet) Remove(items ...string)
Remove removes the items (one or more) from the set.
func (*MultiStringSet) String ¶
func (set *MultiStringSet) String() string
String returns a string representation of container
func (*MultiStringSet) UnmarshalJSON ¶
func (set *MultiStringSet) UnmarshalJSON(data []byte) error
FromJSON populates the set from the input JSON representation.
func (*MultiStringSet) UpperBound ¶
func (set *MultiStringSet) UpperBound(item string) IteratorMultiStringSet
func (*MultiStringSet) Values ¶
func (set *MultiStringSet) Values() []string
Values returns all items in the set.
type StringSet ¶
Set holds elements in a red-black Tree
func CopyFromStringSet ¶
func NewStringSet ¶
func (*StringSet) AddItem ¶
Add adds the item one to the set.Returns false and the interface if it already exists
func (*StringSet) Begin ¶
func (set *StringSet) Begin() IteratorStringSet
Begin returns First Iterator whose position points to the first element Return End Iterator when the map is empty
func (*StringSet) Contains ¶
Contains checks weather items (one or more) are present in the set. All items have to be present in the set for the method to return true. Returns true if no arguments are passed at all, i.e. set is always superset of empty set.
func (*StringSet) Each ¶
Each calls the given function once for each element, passing that element's index and value.
func (*StringSet) Find ¶
Find passes each element of the container to the given function and returns the first (index,value) for which the function is true or -1,nil otherwise if no element matches the criteria.
func (*StringSet) Iterator ¶
func (set *StringSet) Iterator() IteratorStringSet
Iterator holding the iterator's state
func (*StringSet) LowerBound ¶
func (set *StringSet) LowerBound(item string) IteratorStringSet
func (StringSet) MarshalJSON ¶
ToJSON outputs the JSON representation of the set.
func (*StringSet) UnmarshalJSON ¶
FromJSON populates the set from the input JSON representation.
func (*StringSet) UpperBound ¶
func (set *StringSet) UpperBound(item string) IteratorStringSet