Documentation ¶
Index ¶
- type LessFunc
- type Node
- func (node *Node[K, V]) GetChildByIndex(i int) *Node[K, V]
- func (node *Node[K, V]) Key() K
- func (node *Node[K, V]) Next() *Node[K, V]
- func (node *Node[K, V]) NumChild() int
- func (node *Node[K, V]) Parent() *Node[K, V]
- func (node *Node[K, V]) Prev() *Node[K, V]
- func (node *Node[K, V]) SetValue(value V)
- func (node *Node[K, V]) Value() V
- type RBTree
- func (tree *RBTree[K, V]) Clear()
- func (tree RBTree[K, V]) Contains(key K) bool
- func (tree *RBTree[K, V]) Erase(node *Node[K, V]) bool
- func (tree RBTree[K, V]) Find(key K) *Node[K, V]
- func (tree RBTree[K, V]) First() *Node[K, V]
- func (tree RBTree[K, V]) Get(key K) V
- func (tree *RBTree[K, V]) Insert(key K, value V) (*Node[K, V], bool)
- func (tree *RBTree[K, V]) Keys() []K
- func (tree RBTree[K, V]) Last() *Node[K, V]
- func (tree RBTree[K, V]) Len() int
- func (tree *RBTree[K, V]) Remove(key K) bool
- func (tree RBTree[K, V]) Root() *Node[K, V]
- func (tree *RBTree[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node[K comparable, V any] struct { // contains filtered or unexported fields }
Node represents the Node of RBTree
func (*Node[K, V]) GetChildByIndex ¶
GetChildByIndex implements container.Node GetChildByIndex method
type RBTree ¶
type RBTree[K comparable, V any] struct { // contains filtered or unexported fields }
RBTree represents an red-black tree
func New ¶
func New[K constraints.Ordered, V any]() *RBTree[K, V]
New creates an RBTree for ordered K
func NewFunc ¶
func NewFunc[K comparable, V any](less LessFunc[K]) *RBTree[K, V]
NewFunc creates an RBTree with custom less function
func (*RBTree[K, V]) 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[K, V]) Keys ¶
func (tree *RBTree[K, V]) Keys() []K
Keys collects all keys of the tree as a slice
Click to show internal directories.
Click to hide internal directories.