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
Index ¶
- Variables
- func SetIntersection(a *Set, b *Set, callback func(elem V))
- type Iterator
- type Set
- func (set *Set) Add(items ...V)
- func (set *Set) AddItem(item V) (bool, V)
- func (set *Set) Begin() Iterator
- func (set *Set) Contains(items ...V) bool
- func (set *Set) Each(f func(value V))
- func (set *Set) End() Iterator
- func (set *Set) Find(f func(value V) bool) (v V)
- func (set *Set) Iterator() Iterator
- func (set *Set) LowerBound(item V) Iterator
- func (set Set) MarshalJSON() ([]byte, error)
- func (set Set) Pack() (re []byte, err error)
- func (set *Set) Remove(items ...V)
- func (set *Set) String() string
- func (set *Set) UnmarshalJSON(data []byte) error
- func (set *Set) Unpack(in []byte) (int, error)
- func (set *Set) UpperBound(item V) Iterator
- func (set *Set) Values() []V
- type V
Constants ¶
This section is empty.
Variables ¶
var Compare = func(a, b interface{}) int { return container.IntComparator(a.(int), b.(int)) }
var Multi = false
Functions ¶
func SetIntersection ¶
Types ¶
type Set ¶
Set holds elements in a red-black Tree
func (*Set) AddItem ¶
Add adds the item one to the set.Returns false and the interface if it already exists
func (*Set) Begin ¶
Begin returns First Iterator whose position points to the first element Return End Iterator when the map is empty
func (*Set) 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 (*Set) Each ¶
Each calls the given function once for each element, passing that element's index and value.
func (*Set) 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 (*Set) LowerBound ¶
func (Set) MarshalJSON ¶
ToJSON outputs the JSON representation of the set.
func (*Set) UnmarshalJSON ¶
FromJSON populates the set from the input JSON representation.