Documentation ¶
Index ¶
- Constants
- type BST
- type Color
- type Compare
- type RBNode
- func (n *RBNode[K, T]) Color() Color
- func (n *RBNode[K, T]) Grandparent() *RBNode[K, T]
- func (n *RBNode[K, T]) IsBlack() bool
- func (n *RBNode[K, T]) IsLeftChild() bool
- func (n *RBNode[K, T]) IsRed() bool
- func (n *RBNode[K, T]) IsRightChild() bool
- func (n *RBNode[K, T]) Left() *RBNode[K, T]
- func (n *RBNode[K, T]) Parent() *RBNode[K, T]
- func (n *RBNode[K, T]) Right() *RBNode[K, T]
- func (n *RBNode[K, T]) Sibling() *RBNode[K, T]
- func (n *RBNode[K, T]) Uncle() *RBNode[K, T]
- type RBTree
- func (t *RBTree[K, T]) Delete(n *RBNode[K, T]) bool
- func (t *RBTree[K, T]) DeleteUnsafe(n *RBNode[K, T])
- func (t *RBTree[K, T]) Insert(key K, data T) (*RBNode[K, T], bool)
- func (t *RBTree[K, T]) InsertNode(n *RBNode[K, T]) (*RBNode[K, T], bool)
- func (t *RBTree[K, T]) Leftmost() *RBNode[K, T]
- func (t *RBTree[K, T]) Max(n *RBNode[K, T]) *RBNode[K, T]
- func (t *RBTree[K, T]) Min(n *RBNode[K, T]) *RBNode[K, T]
- func (t *RBTree[K, T]) Next(n *RBNode[K, T]) *RBNode[K, T]
- func (t *RBTree[K, T]) Print()
- func (t *RBTree[K, T]) Rightmost() *RBNode[K, T]
- func (t *RBTree[K, T]) RotateLeft(n *RBNode[K, T])
- func (t *RBTree[K, T]) RotateRight(n *RBNode[K, T])
- func (t *RBTree[K, T]) Search(key K) *RBNode[K, T]
- func (t *RBTree[K, T]) Walk(f func(int, bool, *RBNode[K, T]))
Constants ¶
View Source
const ( LESS = iota - 1 EQUAL GREATER )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BST ¶
type BST[K constraints.Ordered, T any] struct { // contains filtered or unexported fields }
type Compare ¶ added in v1.0.4
this comparator sucks. However, we have to use it because when we need to use a custom comparator and this comparator is the fastest way to compare generics.
type RBNode ¶
func (*RBNode[K, T]) Grandparent ¶
func (*RBNode[K, T]) IsLeftChild ¶
func (*RBNode[K, T]) IsRightChild ¶
type RBTree ¶
func (*RBTree[K, T]) DeleteUnsafe ¶ added in v1.0.8
Unsafe delete, it will not check wether the n is in the tree if n is not in the tree, it will panic. this function is for performance when you can ensure n is in the tree, otherwise, use Delete() instead.
func (*RBTree[K, T]) Insert ¶
Insert a key and data into the RBTree, if the key exists, return the node and wether it's inserted or not.
func (*RBTree[K, T]) InsertNode ¶ added in v1.0.1
func (*RBTree[K, T]) RotateLeft ¶
| | N S / \ l-rotate(N) / \ L S ==========> N R / \ / \ M R L M
func (*RBTree[K, T]) RotateRight ¶
| | N L / \ r-rotate(N) / \ L S ==========> M N / \ / \ M R R S
Click to show internal directories.
Click to hide internal directories.