Documentation
¶
Index ¶
- type CompareFunc
- type FormatOptions
- type Iterator
- type K
- type RBTree
- func (tree *RBTree) Clear()
- func (tree *RBTree) Erase(iter Iterator) bool
- func (tree *RBTree) Find(key K) Iterator
- func (tree *RBTree) First() Iterator
- func (tree *RBTree) Format(options FormatOptions) string
- func (tree *RBTree) Insert(key K, value V) (Iterator, bool)
- func (tree *RBTree) Last() Iterator
- func (tree RBTree) Len() int
- func (tree *RBTree) MarshalTree(prefix string) string
- func (tree *RBTree) Remove(key K) bool
- func (tree *RBTree) String() string
- type V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompareFunc ¶
CompareFunc represents comparation between key
type FormatOptions ¶
FormatOptions contains options for formatting RBTree
type Iterator ¶
type Iterator interface {
// Prev returns previous iterator
Prev() Iterator
// Next returns next node iterator
Next() Iterator
// Key returns key of the node
Key() K
// Value returns value of the node
Value() V
// SetValue sets value of the node
SetValue(V)
// contains filtered or unexported methods
}
Iterator represents an iterator of RBTree to iterate nodes
type RBTree ¶
type RBTree struct {
// contains filtered or unexported fields
}
RBTree RBComment
func (*RBTree) First ¶
First returns the first node.
usage:
iter := tree.First()
for iter != nil {
// hint: do something here using iter
// hint: iter.Key(), iter.Value(), iter.SetValue(newValue)
iter = iter.Next()
}
func (*RBTree) Format ¶
func (tree *RBTree) Format(options FormatOptions) string
Format formats the tree
func (*RBTree) Insert ¶
Insert inserts a key-value pair, inserted node and true returned if the key not found, otherwise, existed node and false returned.
func (*RBTree) Last ¶
Last returns the first node.
usage:
iter := tree.Last()
for iter != nil {
// hint: do something here using iter
// hint: iter.Key(), iter.Value(), iter.SetValue(newValue)
iter = iter.Prev()
}
func (*RBTree) MarshalTree ¶
MarshalTree returns a pretty output as a tree
Click to show internal directories.
Click to hide internal directories.