treeset

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2016 License: BSD-2-Clause Imports: 6 Imported by: 243

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

func (*Iterator) Index

func (iterator *Iterator) Index() int

Returns the current element's index. Does not modify the state of the iterator.

func (*Iterator) Next

func (iterator *Iterator) Next() bool

Moves the iterator to the next element and returns true if there was a next element in the container. If Next() returns true, then next element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.

func (*Iterator) Value

func (iterator *Iterator) Value() interface{}

Returns the current element's value. Does not modify the state of the iterator.

type Set

type Set struct {
	// contains filtered or unexported fields
}

func NewWith

func NewWith(comparator utils.Comparator) *Set

Instantiates a new empty set with the custom comparator.

func NewWithIntComparator

func NewWithIntComparator() *Set

Instantiates a new empty set with the IntComparator, i.e. keys are of type int.

func NewWithStringComparator

func NewWithStringComparator() *Set

Instantiates a new empty set with the StringComparator, i.e. keys are of type string.

func (*Set) Add

func (set *Set) Add(items ...interface{})

Adds the items (one or more) to the set.

func (*Set) All

func (set *Set) All(f func(index int, value interface{}) bool) bool

Passes each element of the container to the given function and returns true if the function returns true for all elements.

func (*Set) Any

func (set *Set) Any(f func(index int, value interface{}) bool) bool

Passes each element of the container to the given function and returns true if the function ever returns true for any element.

func (*Set) Clear

func (set *Set) Clear()

Clears all values in the set.

func (*Set) Contains

func (set *Set) Contains(items ...interface{}) bool

Check 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

func (set *Set) Each(f func(index int, value interface{}))

Calls the given function once for each element, passing that element's index and value.

func (*Set) Empty

func (set *Set) Empty() bool

Returns true if set does not contain any elements.

func (*Set) Find

func (set *Set) Find(f func(index int, value interface{}) bool) (int, interface{})

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) Iterator

func (set *Set) Iterator() Iterator

Returns a stateful iterator whose values can be fetched by an index.

func (*Set) Map

func (set *Set) Map(f func(index int, value interface{}) interface{}) *Set

Invokes the given function once for each element and returns a container containing the values returned by the given function.

func (*Set) Remove

func (set *Set) Remove(items ...interface{})

Removes the items (one or more) from the set.

func (*Set) Select

func (set *Set) Select(f func(index int, value interface{}) bool) *Set

Returns a new container containing all elements for which the given function returns a true value.

func (*Set) Size

func (set *Set) Size() int

Returns number of elements within the set.

func (*Set) String

func (set *Set) String() string

func (*Set) Values

func (set *Set) Values() []interface{}

Returns all items in the set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL