Documentation ¶
Overview ¶
Package redgreen contains a generic implementation of a red-green binary search tree.
Index ¶
- type SearchTree
- func (t *SearchTree[K, V]) Find(key K) (V, bool)
- func (t *SearchTree[K, V]) Height() int
- func (t *SearchTree[K, V]) Insert(key K, value V) (V, bool)
- func (t *SearchTree[K, V]) IsEmpty() bool
- func (t *SearchTree[K, V]) List() lang.Iterator[container.KV[K, V]]
- func (t *SearchTree[K, V]) Remove(key K) (V, bool)
- func (t *SearchTree[K, V]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SearchTree ¶
type SearchTree[K, V any] struct { // contains filtered or unexported fields }
SearchTree is a red-green binary search tree, based on CLRS 4th edition. Not thread-safe.
func New ¶
func New[K constraints.Ordered, V any]() *SearchTree[K, V]
New returns is a self-balancing red-green binary search tree. Not thread-safe.
func NewT ¶
func NewT[K, V any](cmp lang.CompareFn[K]) *SearchTree[K, V]
NewT returns is a self-balancing red-green binary search tree. Not thread-safe.
func (*SearchTree[K, V]) Find ¶
func (t *SearchTree[K, V]) Find(key K) (V, bool)
func (*SearchTree[K, V]) Height ¶
func (t *SearchTree[K, V]) Height() int
Height returns the height of the tree, i.e., the number of nodes on the longest path.
func (*SearchTree[K, V]) Insert ¶
func (t *SearchTree[K, V]) Insert(key K, value V) (V, bool)
func (*SearchTree[K, V]) IsEmpty ¶
func (t *SearchTree[K, V]) IsEmpty() bool
func (*SearchTree[K, V]) Remove ¶
func (t *SearchTree[K, V]) Remove(key K) (V, bool)
func (*SearchTree[K, V]) String ¶
func (t *SearchTree[K, V]) String() string
Click to show internal directories.
Click to hide internal directories.