Documentation
¶
Index ¶
- Constants
- type AVL
- func (a *AVL[T]) Add(id T, v int64)
- func (a *AVL[T]) Delete(id T)
- func (a AVL[T]) Fairshare(cap int64) int64
- func (a AVL[T]) Get(id T) *Node[T]
- func (a AVL[T]) GraphDot() string
- func (a *AVL[T]) Insert(id T, v int64)
- func (a AVL[T]) Len() int64
- func (a AVL[T]) Range(from, to int64) iter.Seq[*Node[T]]
- func (a *AVL[T]) Replace(id T, newV int64)
- func (a AVL[T]) String() string
- func (a AVL[T]) Sum() int64
- type Node
Constants ¶
View Source
const Unbounded int64 = -1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AVL ¶
type AVL[T comparable] struct { // contains filtered or unexported fields }
Basic AVL tree implementation.
Nodes require an ID (for example a job ID) for insertion. The ID itself is not used for any balancing. IDs are assumed to be unique.
It supports multiple nodes with the same values. Hence why retrieving a value bases bases around ranges.
func (AVL[T]) Fairshare ¶
Fairshare determines the maximum allowed capacity for all added nodes to be fairshared.
func (AVL[T]) Range ¶
Range returns an iterator of nodes with values in the range [from, to). avl.Unbounded may be passed in to either argument to include all elements from either range.
type Node ¶
type Node[T comparable] struct { ID T // h is the height of its children. 0 if it has no children. Value int64 Parent, L, R *Node[T] // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.