Documentation ¶
Index ¶
- Constants
- Variables
- type FinalIndex
- type FinalNode
- type Iterator
- func (iterator *Iterator) Begin()
- func (iterator *Iterator) Delete()
- func (iterator *Iterator) End()
- func (iterator Iterator) HasNext() bool
- func (iterator *Iterator) HasPrev() bool
- func (iterator Iterator) IsBegin() bool
- func (iterator Iterator) IsEnd() bool
- func (iterator Iterator) Key() Key
- func (iterator *Iterator) Next() bool
- func (iterator *Iterator) Prev() bool
- func (iterator Iterator) Value() Value
- type Key
- type OrderedIndex
- func (tree *OrderedIndex) Begin() Iterator
- func (tree *OrderedIndex) Clear()
- func (tree *OrderedIndex) Empty() bool
- func (tree *OrderedIndex) End() Iterator
- func (tree *OrderedIndex) Erase(iter Iterator) (itr Iterator)
- func (tree *OrderedIndex) Erases(first, last Iterator)
- func (tree *OrderedIndex) Find(key Key) Iterator
- func (tree *OrderedIndex) Insert(v Value) (Iterator, bool)
- func (tree *OrderedIndex) Iterator() Iterator
- func (tree *OrderedIndex) Keys() []Key
- func (tree *OrderedIndex) Left() *OrderedIndexNode
- func (tree *OrderedIndex) LowerBound(key Key) Iterator
- func (tree *OrderedIndex) Modify(iter Iterator, mod func(*Value)) bool
- func (tree *OrderedIndex) Remove(key Key)
- func (tree *OrderedIndex) Right() *OrderedIndexNode
- func (tree *OrderedIndex) Size() int
- func (tree *OrderedIndex) String() string
- func (tree *OrderedIndex) UpperBound(key Key) Iterator
- func (tree *OrderedIndex) Values() []Value
- type OrderedIndexNode
- type SuperIndex
- type SuperNode
- type Value
Constants ¶
const Multiply = false
Variables ¶
var Comparator = func(a, b Key) int { return 0 }
var KeyFunc = func(v Value) Key { return v }
Functions ¶
This section is empty.
Types ¶
type FinalIndex ¶
type FinalIndex struct {
// contains filtered or unexported fields
}
generic class
type FinalNode ¶
type FinalNode struct { GetSuperNode func() interface{} GetFinalNode func() interface{} }
generic class
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator holding the iterator's state
func (*Iterator) Begin ¶
func (iterator *Iterator) Begin()
Begin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.
func (*Iterator) Delete ¶
func (iterator *Iterator) Delete()
Delete remove the node which pointed by the iterator Modifies the state of the iterator.
func (*Iterator) End ¶
func (iterator *Iterator) End()
End moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.
func (Iterator) Key ¶
Key returns the current element's key. Does not modify the state of the iterator.
func (*Iterator) Next ¶
Next 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 key and value can be retrieved by Key() and Value(). If Next() was called for the first time, then it will point the iterator to the first element if it exists. Modifies the state of the iterator.
type OrderedIndex ¶
type OrderedIndex struct { Root *OrderedIndexNode // contains filtered or unexported fields }
OrderedIndex holds elements of the red-black tree
func (*OrderedIndex) Begin ¶
func (tree *OrderedIndex) Begin() Iterator
func (*OrderedIndex) Clear ¶
func (tree *OrderedIndex) Clear()
Clear removes all nodes from the tree.
func (*OrderedIndex) Empty ¶
func (tree *OrderedIndex) Empty() bool
Empty returns true if tree does not contain any nodes
func (*OrderedIndex) End ¶
func (tree *OrderedIndex) End() Iterator
func (*OrderedIndex) Erase ¶
func (tree *OrderedIndex) Erase(iter Iterator) (itr Iterator)
func (*OrderedIndex) Erases ¶
func (tree *OrderedIndex) Erases(first, last Iterator)
func (*OrderedIndex) Find ¶
func (tree *OrderedIndex) Find(key Key) Iterator
Get searches the node in the tree 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 (*OrderedIndex) Iterator ¶
func (tree *OrderedIndex) Iterator() Iterator
Iterator returns a stateful iterator whose elements are key/value pairs.
func (*OrderedIndex) Left ¶
func (tree *OrderedIndex) Left() *OrderedIndexNode
Left returns the left-most (min) node or nil if tree is empty.
func (*OrderedIndex) LowerBound ¶
func (tree *OrderedIndex) LowerBound(key Key) Iterator
LowerBound returns an iterator pointing to the first element that is not less than the given key. Complexity: O(log N).
func (*OrderedIndex) Modify ¶
func (tree *OrderedIndex) Modify(iter Iterator, mod func(*Value)) bool
func (*OrderedIndex) Remove ¶
func (tree *OrderedIndex) Remove(key Key)
Remove remove the node from the tree by key. Key should adhere to the comparator's type assertion, otherwise method panics.
func (*OrderedIndex) Right ¶
func (tree *OrderedIndex) Right() *OrderedIndexNode
Right returns the right-most (max) node or nil if tree is empty.
func (*OrderedIndex) Size ¶
func (tree *OrderedIndex) Size() int
Size returns number of nodes in the tree.
func (*OrderedIndex) String ¶
func (tree *OrderedIndex) String() string
String returns a string representation of container
func (*OrderedIndex) UpperBound ¶
func (tree *OrderedIndex) UpperBound(key Key) Iterator
UpperBound returns an iterator pointing to the first element that is greater than the given key. Complexity: O(log N).
func (*OrderedIndex) Values ¶
func (tree *OrderedIndex) Values() []Value
Values returns all values in-order based on the key.
type OrderedIndexNode ¶
type OrderedIndexNode struct { Key Key Left *OrderedIndexNode Right *OrderedIndexNode Parent *OrderedIndexNode // contains filtered or unexported fields }
OrderedIndexNode is a single element within the tree
func (*OrderedIndexNode) String ¶
func (node *OrderedIndexNode) String() string
type SuperIndex ¶
type SuperIndex struct {
// contains filtered or unexported fields
}
generic class