example

package
v0.0.0-...-c626c17 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package treemap implements a map backed by red-black Tree.

Elements are ordered by key in the map.

Structure is not thread safe.

Reference: http://en.wikipedia.org/wiki/Associative_array

Package treemap implements a map backed by red-black Tree.

Elements are ordered by key in the map.

Structure is not thread safe.

Reference: http://en.wikipedia.org/wiki/Associative_array

Package treemap implements a map backed by red-black Tree.

Elements are ordered by key in the map.

Structure is not thread safe.

Reference: http://en.wikipedia.org/wiki/Associative_array

Package treemap implements a map backed by red-black Tree.

Elements are ordered by key in the map.

Structure is not thread safe.

Reference: http://en.wikipedia.org/wiki/Associative_array

Package treemap implements a map backed by red-black Tree.

Elements are ordered by key in the map.

Structure is not thread safe.

Reference: http://en.wikipedia.org/wiki/Associative_array

Package treemap implements a map backed by red-black Tree.

Elements are ordered by key in the map.

Structure is not thread safe.

Reference: http://en.wikipedia.org/wiki/Associative_array

Index

Constants

This section is empty.

Variables

View Source
var IntComparator = func(a, b interface{}) int { return container.IntComparator(a.(int), b.(int)) }
View Source
var StringComparator = func(a, b interface{}) int { return container.StringComparator(a.(string), b.(string)) }

Functions

This section is empty.

Types

type IntStringMap

type IntStringMap struct {
	*rbt.Tree
}

Map holds the elements in a red-black Tree

func CopyFromIntStringMap

func CopyFromIntStringMap(tm *IntStringMap) *IntStringMap

func NewIntStringMap

func NewIntStringMap() *IntStringMap

NewWith instantiates a Tree map with the custom comparator.

func (*IntStringMap) Begin

Begin returns First Iterator whose position points to the first element Return End Iterator when the map is empty

func (*IntStringMap) Each

func (m *IntStringMap) Each(f func(key int, value string))

Each calls the given function once for each element, passing that element's key and value.

func (*IntStringMap) End

End returns End Iterator

func (*IntStringMap) Find

func (m *IntStringMap) Find(f func(key int, value string) bool) (k int, v string)

Find passes each element of the container to the given function and returns the first (key,value) for which the function is true or nil,nil otherwise if no element matches the criteria.

func (*IntStringMap) Get

Get searches the element in the map by key and returns its value or nil if key is not found in Tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*IntStringMap) Insert

func (m *IntStringMap) Insert(key int, value string) IteratorIntStringMap

func (*IntStringMap) Iterator

func (m *IntStringMap) Iterator() IteratorIntStringMap

Iterator returns a stateful Iterator whose elements are key/value pairs.

func (*IntStringMap) Keys

func (m *IntStringMap) Keys() []int

Keys returns all keys in-order

func (*IntStringMap) LowerBound

func (m *IntStringMap) LowerBound(key int) IteratorIntStringMap

func (IntStringMap) MarshalJSON

func (m IntStringMap) MarshalJSON() ([]byte, error)

func (IntStringMap) Pack

func (m IntStringMap) Pack() (re []byte, err error)

func (*IntStringMap) Put

func (m *IntStringMap) Put(key int, value string)

Put inserts key-value pair into the map. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*IntStringMap) Remove

func (m *IntStringMap) Remove(key int)

Remove removes the element from the map by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (IntStringMap) String

func (m IntStringMap) String() string

String returns a string representation of container

func (*IntStringMap) UnmarshalJSON

func (m *IntStringMap) UnmarshalJSON(data []byte) error

FromJSON populates the map from the input JSON representation.

func (*IntStringMap) Unpack

func (m *IntStringMap) Unpack(in []byte) (int, error)

func (*IntStringMap) UpperBound

func (m *IntStringMap) UpperBound(key int) IteratorIntStringMap

func (*IntStringMap) Values

func (m *IntStringMap) Values() []string

Values returns all values in-order based on the key.

type IntStringPtrMap

type IntStringPtrMap struct {
	*rbt.Tree
}

Map holds the elements in a red-black Tree

func CopyFromIntStringPtrMap

func CopyFromIntStringPtrMap(tm *IntStringPtrMap) *IntStringPtrMap

func NewIntStringPtrMap

func NewIntStringPtrMap() *IntStringPtrMap

NewWith instantiates a Tree map with the custom comparator.

func (*IntStringPtrMap) Begin

Begin returns First Iterator whose position points to the first element Return End Iterator when the map is empty

func (*IntStringPtrMap) Each

func (m *IntStringPtrMap) Each(f func(key int, value *string))

Each calls the given function once for each element, passing that element's key and value.

func (*IntStringPtrMap) End

End returns End Iterator

func (*IntStringPtrMap) Find

func (m *IntStringPtrMap) Find(f func(key int, value *string) bool) (k int, v *string)

Find passes each element of the container to the given function and returns the first (key,value) for which the function is true or nil,nil otherwise if no element matches the criteria.

func (*IntStringPtrMap) Get

Get searches the element in the map by key and returns its value or nil if key is not found in Tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*IntStringPtrMap) Insert

func (m *IntStringPtrMap) Insert(key int, value *string) IteratorIntStringPtrMap

func (*IntStringPtrMap) Iterator

Iterator returns a stateful Iterator whose elements are key/value pairs.

func (*IntStringPtrMap) Keys

func (m *IntStringPtrMap) Keys() []int

Keys returns all keys in-order

func (*IntStringPtrMap) LowerBound

func (m *IntStringPtrMap) LowerBound(key int) IteratorIntStringPtrMap

func (IntStringPtrMap) MarshalJSON

func (m IntStringPtrMap) MarshalJSON() ([]byte, error)

func (IntStringPtrMap) Pack

func (m IntStringPtrMap) Pack() (re []byte, err error)

func (*IntStringPtrMap) Put

func (m *IntStringPtrMap) Put(key int, value *string)

Put inserts key-value pair into the map. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*IntStringPtrMap) Remove

func (m *IntStringPtrMap) Remove(key int)

Remove removes the element from the map by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (IntStringPtrMap) String

func (m IntStringPtrMap) String() string

String returns a string representation of container

func (*IntStringPtrMap) UnmarshalJSON

func (m *IntStringPtrMap) UnmarshalJSON(data []byte) error

FromJSON populates the map from the input JSON representation.

func (*IntStringPtrMap) Unpack

func (m *IntStringPtrMap) Unpack(in []byte) (int, error)

func (*IntStringPtrMap) UpperBound

func (m *IntStringPtrMap) UpperBound(key int) IteratorIntStringPtrMap

func (*IntStringPtrMap) Values

func (m *IntStringPtrMap) Values() []*string

Values returns all values in-order based on the key.

type IteratorIntStringMap

type IteratorIntStringMap struct {
	rbt.Iterator
}

Iterator holding the Iterator's state

func (IteratorIntStringMap) Key

func (iterator IteratorIntStringMap) Key() int

Key returns the current element's key. Does not modify the state of the Iterator.

func (IteratorIntStringMap) Value

func (iterator IteratorIntStringMap) Value() string

Value returns the current element's value. Does not modify the state of the Iterator.

type IteratorIntStringPtrMap

type IteratorIntStringPtrMap struct {
	rbt.Iterator
}

Iterator holding the Iterator's state

func (IteratorIntStringPtrMap) Key

func (iterator IteratorIntStringPtrMap) Key() int

Key returns the current element's key. Does not modify the state of the Iterator.

func (IteratorIntStringPtrMap) Value

func (iterator IteratorIntStringPtrMap) Value() *string

Value returns the current element's value. Does not modify the state of the Iterator.

type IteratorMultiIntStringMap

type IteratorMultiIntStringMap struct {
	rbt.Iterator
}

Iterator holding the Iterator's state

func (IteratorMultiIntStringMap) Key

func (iterator IteratorMultiIntStringMap) Key() int

Key returns the current element's key. Does not modify the state of the Iterator.

func (IteratorMultiIntStringMap) Value

func (iterator IteratorMultiIntStringMap) Value() string

Value returns the current element's value. Does not modify the state of the Iterator.

type IteratorMultiIntStringPtrMap

type IteratorMultiIntStringPtrMap struct {
	rbt.Iterator
}

Iterator holding the Iterator's state

func (IteratorMultiIntStringPtrMap) Key

func (iterator IteratorMultiIntStringPtrMap) Key() int

Key returns the current element's key. Does not modify the state of the Iterator.

func (IteratorMultiIntStringPtrMap) Value

func (iterator IteratorMultiIntStringPtrMap) Value() *string

Value returns the current element's value. Does not modify the state of the Iterator.

type IteratorMultiStringIntMap

type IteratorMultiStringIntMap struct {
	rbt.Iterator
}

Iterator holding the Iterator's state

func (IteratorMultiStringIntMap) Key

func (iterator IteratorMultiStringIntMap) Key() string

Key returns the current element's key. Does not modify the state of the Iterator.

func (IteratorMultiStringIntMap) Value

func (iterator IteratorMultiStringIntMap) Value() int

Value returns the current element's value. Does not modify the state of the Iterator.

type IteratorStringIntMap

type IteratorStringIntMap struct {
	rbt.Iterator
}

Iterator holding the Iterator's state

func (IteratorStringIntMap) Key

func (iterator IteratorStringIntMap) Key() string

Key returns the current element's key. Does not modify the state of the Iterator.

func (IteratorStringIntMap) Value

func (iterator IteratorStringIntMap) Value() int

Value returns the current element's value. Does not modify the state of the Iterator.

type MultiIntStringMap

type MultiIntStringMap struct {
	*rbt.Tree
}

Map holds the elements in a red-black Tree

func CopyFromMultiIntStringMap

func CopyFromMultiIntStringMap(tm *MultiIntStringMap) *MultiIntStringMap

func NewMultiIntStringMap

func NewMultiIntStringMap() *MultiIntStringMap

NewWith instantiates a Tree map with the custom comparator.

func (*MultiIntStringMap) Begin

Begin returns First Iterator whose position points to the first element Return End Iterator when the map is empty

func (*MultiIntStringMap) Each

func (m *MultiIntStringMap) Each(f func(key int, value string))

Each calls the given function once for each element, passing that element's key and value.

func (*MultiIntStringMap) End

End returns End Iterator

func (*MultiIntStringMap) Find

func (m *MultiIntStringMap) Find(f func(key int, value string) bool) (k int, v string)

Find passes each element of the container to the given function and returns the first (key,value) for which the function is true or nil,nil otherwise if no element matches the criteria.

func (*MultiIntStringMap) Get

Get searches the element in the map by key and returns its value or nil if key is not found in Tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*MultiIntStringMap) Insert

func (m *MultiIntStringMap) Insert(key int, value string) IteratorMultiIntStringMap

func (*MultiIntStringMap) Iterator

Iterator returns a stateful Iterator whose elements are key/value pairs.

func (*MultiIntStringMap) Keys

func (m *MultiIntStringMap) Keys() []int

Keys returns all keys in-order

func (*MultiIntStringMap) LowerBound

func (m *MultiIntStringMap) LowerBound(key int) IteratorMultiIntStringMap

func (MultiIntStringMap) MarshalJSON

func (m MultiIntStringMap) MarshalJSON() ([]byte, error)

func (MultiIntStringMap) Pack

func (m MultiIntStringMap) Pack() (re []byte, err error)

func (*MultiIntStringMap) Put

func (m *MultiIntStringMap) Put(key int, value string)

Put inserts key-value pair into the map. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*MultiIntStringMap) Remove

func (m *MultiIntStringMap) Remove(key int)

Remove removes the element from the map by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (MultiIntStringMap) String

func (m MultiIntStringMap) String() string

String returns a string representation of container

func (*MultiIntStringMap) UnmarshalJSON

func (m *MultiIntStringMap) UnmarshalJSON(data []byte) error

FromJSON populates the map from the input JSON representation.

func (*MultiIntStringMap) Unpack

func (m *MultiIntStringMap) Unpack(in []byte) (int, error)

func (*MultiIntStringMap) UpperBound

func (m *MultiIntStringMap) UpperBound(key int) IteratorMultiIntStringMap

func (*MultiIntStringMap) Values

func (m *MultiIntStringMap) Values() []string

Values returns all values in-order based on the key.

type MultiIntStringPtrMap

type MultiIntStringPtrMap struct {
	*rbt.Tree
}

Map holds the elements in a red-black Tree

func CopyFromMultiIntStringPtrMap

func CopyFromMultiIntStringPtrMap(tm *MultiIntStringPtrMap) *MultiIntStringPtrMap

func NewMultiIntStringPtrMap

func NewMultiIntStringPtrMap() *MultiIntStringPtrMap

NewWith instantiates a Tree map with the custom comparator.

func (*MultiIntStringPtrMap) Begin

Begin returns First Iterator whose position points to the first element Return End Iterator when the map is empty

func (*MultiIntStringPtrMap) Each

func (m *MultiIntStringPtrMap) Each(f func(key int, value *string))

Each calls the given function once for each element, passing that element's key and value.

func (*MultiIntStringPtrMap) End

End returns End Iterator

func (*MultiIntStringPtrMap) Find

func (m *MultiIntStringPtrMap) Find(f func(key int, value *string) bool) (k int, v *string)

Find passes each element of the container to the given function and returns the first (key,value) for which the function is true or nil,nil otherwise if no element matches the criteria.

func (*MultiIntStringPtrMap) Get

Get searches the element in the map by key and returns its value or nil if key is not found in Tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*MultiIntStringPtrMap) Insert

func (*MultiIntStringPtrMap) Iterator

Iterator returns a stateful Iterator whose elements are key/value pairs.

func (*MultiIntStringPtrMap) Keys

func (m *MultiIntStringPtrMap) Keys() []int

Keys returns all keys in-order

func (*MultiIntStringPtrMap) LowerBound

func (MultiIntStringPtrMap) MarshalJSON

func (m MultiIntStringPtrMap) MarshalJSON() ([]byte, error)

func (MultiIntStringPtrMap) Pack

func (m MultiIntStringPtrMap) Pack() (re []byte, err error)

func (*MultiIntStringPtrMap) Put

func (m *MultiIntStringPtrMap) Put(key int, value *string)

Put inserts key-value pair into the map. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*MultiIntStringPtrMap) Remove

func (m *MultiIntStringPtrMap) Remove(key int)

Remove removes the element from the map by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (MultiIntStringPtrMap) String

func (m MultiIntStringPtrMap) String() string

String returns a string representation of container

func (*MultiIntStringPtrMap) UnmarshalJSON

func (m *MultiIntStringPtrMap) UnmarshalJSON(data []byte) error

FromJSON populates the map from the input JSON representation.

func (*MultiIntStringPtrMap) Unpack

func (m *MultiIntStringPtrMap) Unpack(in []byte) (int, error)

func (*MultiIntStringPtrMap) UpperBound

func (*MultiIntStringPtrMap) Values

func (m *MultiIntStringPtrMap) Values() []*string

Values returns all values in-order based on the key.

type MultiStringIntMap

type MultiStringIntMap struct {
	*rbt.Tree
}

Map holds the elements in a red-black Tree

func CopyFromMultiStringIntMap

func CopyFromMultiStringIntMap(tm *MultiStringIntMap) *MultiStringIntMap

func NewMultiStringIntMap

func NewMultiStringIntMap() *MultiStringIntMap

NewWith instantiates a Tree map with the custom comparator.

func (*MultiStringIntMap) Begin

Begin returns First Iterator whose position points to the first element Return End Iterator when the map is empty

func (*MultiStringIntMap) Each

func (m *MultiStringIntMap) Each(f func(key string, value int))

Each calls the given function once for each element, passing that element's key and value.

func (*MultiStringIntMap) End

End returns End Iterator

func (*MultiStringIntMap) Find

func (m *MultiStringIntMap) Find(f func(key string, value int) bool) (k string, v int)

Find passes each element of the container to the given function and returns the first (key,value) for which the function is true or nil,nil otherwise if no element matches the criteria.

func (*MultiStringIntMap) Get

Get searches the element in the map by key and returns its value or nil if key is not found in Tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*MultiStringIntMap) Insert

func (m *MultiStringIntMap) Insert(key string, value int) IteratorMultiStringIntMap

func (*MultiStringIntMap) Iterator

Iterator returns a stateful Iterator whose elements are key/value pairs.

func (*MultiStringIntMap) Keys

func (m *MultiStringIntMap) Keys() []string

Keys returns all keys in-order

func (*MultiStringIntMap) LowerBound

func (MultiStringIntMap) MarshalJSON

func (m MultiStringIntMap) MarshalJSON() ([]byte, error)

func (MultiStringIntMap) Pack

func (m MultiStringIntMap) Pack() (re []byte, err error)

func (*MultiStringIntMap) Put

func (m *MultiStringIntMap) Put(key string, value int)

Put inserts key-value pair into the map. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*MultiStringIntMap) Remove

func (m *MultiStringIntMap) Remove(key string)

Remove removes the element from the map by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (MultiStringIntMap) String

func (m MultiStringIntMap) String() string

String returns a string representation of container

func (*MultiStringIntMap) UnmarshalJSON

func (m *MultiStringIntMap) UnmarshalJSON(data []byte) error

FromJSON populates the map from the input JSON representation.

func (*MultiStringIntMap) Unpack

func (m *MultiStringIntMap) Unpack(in []byte) (int, error)

func (*MultiStringIntMap) UpperBound

func (*MultiStringIntMap) Values

func (m *MultiStringIntMap) Values() []int

Values returns all values in-order based on the key.

type StringIntMap

type StringIntMap struct {
	*rbt.Tree
}

Map holds the elements in a red-black Tree

func CopyFromStringIntMap

func CopyFromStringIntMap(tm *StringIntMap) *StringIntMap

func NewStringIntMap

func NewStringIntMap() *StringIntMap

NewWith instantiates a Tree map with the custom comparator.

func (*StringIntMap) Begin

Begin returns First Iterator whose position points to the first element Return End Iterator when the map is empty

func (*StringIntMap) Each

func (m *StringIntMap) Each(f func(key string, value int))

Each calls the given function once for each element, passing that element's key and value.

func (*StringIntMap) End

End returns End Iterator

func (*StringIntMap) Find

func (m *StringIntMap) Find(f func(key string, value int) bool) (k string, v int)

Find passes each element of the container to the given function and returns the first (key,value) for which the function is true or nil,nil otherwise if no element matches the criteria.

func (*StringIntMap) Get

Get searches the element in the map by key and returns its value or nil if key is not found in Tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*StringIntMap) Insert

func (m *StringIntMap) Insert(key string, value int) IteratorStringIntMap

func (*StringIntMap) Iterator

func (m *StringIntMap) Iterator() IteratorStringIntMap

Iterator returns a stateful Iterator whose elements are key/value pairs.

func (*StringIntMap) Keys

func (m *StringIntMap) Keys() []string

Keys returns all keys in-order

func (*StringIntMap) LowerBound

func (m *StringIntMap) LowerBound(key string) IteratorStringIntMap

func (StringIntMap) MarshalJSON

func (m StringIntMap) MarshalJSON() ([]byte, error)

func (StringIntMap) Pack

func (m StringIntMap) Pack() (re []byte, err error)

func (*StringIntMap) Put

func (m *StringIntMap) Put(key string, value int)

Put inserts key-value pair into the map. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*StringIntMap) Remove

func (m *StringIntMap) Remove(key string)

Remove removes the element from the map by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (StringIntMap) String

func (m StringIntMap) String() string

String returns a string representation of container

func (*StringIntMap) UnmarshalJSON

func (m *StringIntMap) UnmarshalJSON(data []byte) error

FromJSON populates the map from the input JSON representation.

func (*StringIntMap) Unpack

func (m *StringIntMap) Unpack(in []byte) (int, error)

func (*StringIntMap) UpperBound

func (m *StringIntMap) UpperBound(key string) IteratorStringIntMap

func (*StringIntMap) Values

func (m *StringIntMap) Values() []int

Values returns all values in-order based on the key.

Jump to

Keyboard shortcuts

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