Documentation
¶
Overview ¶
Package rbtree implements operations on Red-Black tree.
Index ¶
- Constants
- type Int
- type Item
- type Iterator
- type Node
- type Rbtree
- func (t *Rbtree) Ascend(pivot Item, iterator Iterator)
- func (t *Rbtree) AscendRange(ge, lt Item, iterator Iterator)
- func (t *Rbtree) Delete(item Item) Item
- func (t *Rbtree) Descend(pivot Item, iterator Iterator)
- func (t *Rbtree) First() *Node
- func (t *Rbtree) Get(item Item) Item
- func (t *Rbtree) Init() *Rbtree
- func (t *Rbtree) Insert(item Item) *Node
- func (t *Rbtree) InsertOrGet(item Item) Item
- func (t *Rbtree) Len() uint
- func (t *Rbtree) Max() Item
- func (t *Rbtree) Min() Item
- func (t *Rbtree) Next(x *Node) *Node
- func (t *Rbtree) Prev(x *Node) *Node
- func (t *Rbtree) Search(item Item) *Node
- func (t *Rbtree) SearchLe(item Item) *Node
- func (t *Rbtree) Tail() *Node
- type String
- type Uint32
Constants ¶
const ( RED = true BLACK = false )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
Red-Black tree properties: http://en.wikipedia.org/wiki/Rbtree
- A node is either red or black
- The root is black
- All leaves (NULL) are black
- Both children of every red node are black
- Every simple path from root to leaves contains the same number of black nodes.
type Rbtree ¶
type Rbtree struct { NIL *Node // contains filtered or unexported fields }
Rbtree represents a Red-Black tree.
func (*Rbtree) Ascend ¶
Ascend will call iterator once for each element greater or equal than pivot in ascending order. It will stop whenever the iterator returns false.
func (*Rbtree) AscendRange ¶
AscendRange will call iterator once for elements greater or equal than @ge and less than @lt, which means the range would be [ge, lt). It will stop whenever the iterator returns false.
func (*Rbtree) Descend ¶
Descend will call iterator once for each element less or equal than pivot in descending order. It will stop whenever the iterator returns false.
func (*Rbtree) InsertOrGet ¶
InsertOrGet inserts or retrieves the item in the tree. If the item is already in the tree then the return value will be that. If the item is not in the tree the return value will be the item you put in.