Documentation
¶
Index ¶
- Constants
- type AvlIter
- func (it *AvlIter[T]) CopyFrom(other *AvlIter[T]) (T, bool)
- func (it *AvlIter[T]) Current() (T, bool)
- func (it *AvlIter[T]) Find(item T) (T, bool)
- func (it *AvlIter[T]) First() (T, bool)
- func (it *AvlIter[T]) HookWith(tree *AvlTree[T]) *AvlIter[T]
- func (it *AvlIter[T]) Insert(item T) (*T, bool)
- func (it *AvlIter[T]) Last() (T, bool)
- func (it *AvlIter[T]) Next() (T, bool)
- func (it *AvlIter[T]) Prev() (T, bool)
- func (it *AvlIter[T]) Replace(new T) (T, bool)
- type AvlTree
- func (t *AvlTree[T]) All() iter.Seq[T]
- func (t *AvlTree[T]) Backward() iter.Seq[T]
- func (t *AvlTree[T]) Copy() *AvlTree[T]
- func (t *AvlTree[T]) Count() int
- func (t *AvlTree[T]) Delete(item T) (T, bool)
- func (t *AvlTree[T]) Find(target T) (T, bool)
- func (t *AvlTree[T]) Insert(item T) bool
- func (t *AvlTree[T]) Iter() *AvlIter[T]
- func (t *AvlTree[T]) Replace(item T) (T, bool)
- type Compare
- type Iterator
- type PAvlIter
- func (it *PAvlIter[T]) CopyFrom(other *PAvlIter[T]) (T, bool)
- func (it *PAvlIter[T]) Current() (T, bool)
- func (it *PAvlIter[T]) Find(item T) (T, bool)
- func (it *PAvlIter[T]) First() (T, bool)
- func (it *PAvlIter[T]) HookWith(tree *PAvlTree[T]) *PAvlIter[T]
- func (it *PAvlIter[T]) Insert(item T) (*T, bool)
- func (it *PAvlIter[T]) Last() (T, bool)
- func (it *PAvlIter[T]) Next() (T, bool)
- func (it *PAvlIter[T]) Prev() (T, bool)
- func (it *PAvlIter[T]) Replace(new T) (T, bool)
- type PAvlTree
- func (t *PAvlTree[T]) All() iter.Seq[T]
- func (t *PAvlTree[T]) Backward() iter.Seq[T]
- func (t *PAvlTree[T]) Copy() *PAvlTree[T]
- func (t *PAvlTree[T]) Count() int
- func (t *PAvlTree[T]) Delete(item T) (T, bool)
- func (t *PAvlTree[T]) Find(target T) (T, bool)
- func (t *PAvlTree[T]) Insert(item T) bool
- func (t *PAvlTree[T]) Iter() *PAvlIter[T]
- func (t *PAvlTree[T]) Replace(item T) (T, bool)
- type PRbIter
- func (it *PRbIter[T]) CopyFrom(other *PRbIter[T]) (T, bool)
- func (it *PRbIter[T]) Current() (T, bool)
- func (it *PRbIter[T]) Find(item T) (T, bool)
- func (it *PRbIter[T]) First() (T, bool)
- func (it *PRbIter[T]) HookWith(tree *PRbTree[T]) *PRbIter[T]
- func (it *PRbIter[T]) Insert(item T) (*T, bool)
- func (it *PRbIter[T]) Last() (T, bool)
- func (it *PRbIter[T]) Next() (T, bool)
- func (it *PRbIter[T]) Prev() (T, bool)
- func (it *PRbIter[T]) Replace(new T) (T, bool)
- type PRbTree
- func (t *PRbTree[T]) All() iter.Seq[T]
- func (t *PRbTree[T]) Backward() iter.Seq[T]
- func (t *PRbTree[T]) Copy() *PRbTree[T]
- func (t *PRbTree[T]) Count() int
- func (t *PRbTree[T]) Delete(item T) (T, bool)
- func (t *PRbTree[T]) Find(target T) (T, bool)
- func (t *PRbTree[T]) Insert(item T) bool
- func (t *PRbTree[T]) Iter() *PRbIter[T]
- func (t *PRbTree[T]) Replace(item T) (T, bool)
- type RbIter
- func (it *RbIter[T]) CopyFrom(other *RbIter[T]) (T, bool)
- func (it *RbIter[T]) Current() (T, bool)
- func (it *RbIter[T]) Find(item T) (T, bool)
- func (it *RbIter[T]) First() (T, bool)
- func (it *RbIter[T]) HookWith(tree *RbTree[T]) *RbIter[T]
- func (it *RbIter[T]) Insert(item T) (*T, bool)
- func (it *RbIter[T]) Last() (T, bool)
- func (it *RbIter[T]) Next() (T, bool)
- func (it *RbIter[T]) Prev() (T, bool)
- func (it *RbIter[T]) Replace(new T) (T, bool)
- type RbTree
- func (t *RbTree[T]) All() iter.Seq[T]
- func (t *RbTree[T]) Backward() iter.Seq[T]
- func (t *RbTree[T]) Copy() *RbTree[T]
- func (t *RbTree[T]) Count() int
- func (t *RbTree[T]) Delete(item T) (T, bool)
- func (t *RbTree[T]) Find(target T) (T, bool)
- func (t *RbTree[T]) Insert(item T) bool
- func (t *RbTree[T]) Iter() *RbIter[T]
- func (t *RbTree[T]) Replace(item T) (T, bool)
- type SymTab
Constants ¶
const ( Left = iota Right ChildNum )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvlIter ¶
type AvlIter[T any] struct { // contains filtered or unexported fields }
func NewAvlIter ¶
type AvlTree ¶
type AvlTree[T any] struct { // contains filtered or unexported fields }
func NewAvlTree ¶
NewAvlTree creates a new AVL tree for cmp.Ordered types (int, string, float64, etc.)
func NewAvlTreeFunc ¶
NewAvlTreeFunc creates a new AVL tree with a custom comparison function.
func (*AvlTree[T]) Delete ¶
Delete deletes item from tree. Returns the deleted item and true if found, zero value and false otherwise.
func (*AvlTree[T]) Find ¶
Find searches for target in tree. Returns the item and true if found, zero value and false otherwise.
type Compare ¶
Compare is the comparison function signature for custom types. Returns negative if a < b, positive if a > b, zero if a == b.
func OrderedCompare ¶
OrderedCompare returns the standard comparison function for cmp.Ordered types.
type Iterator ¶
type Iterator[T any] interface { First() (T, bool) Last() (T, bool) Prev() (T, bool) Next() (T, bool) Current() (T, bool) }
Iterator provides bidirectional iteration over tree elements.
type PAvlIter ¶
type PAvlIter[T any] struct { // contains filtered or unexported fields }
func NewPAvlIter ¶
type PAvlTree ¶
type PAvlTree[T any] struct { // contains filtered or unexported fields }
func NewPAvlTree ¶
NewPAvlTree creates a new AVL tree with parent pointers for cmp.Ordered types.
func NewPAvlTreeFunc ¶
NewPAvlTreeFunc creates a new AVL tree with parent pointers using a custom comparison function.
func (*PAvlTree[T]) Backward ¶
Backward returns a reverse iterator for use with range-over-function.
func (*PAvlTree[T]) Delete ¶
Delete deletes item from tree. Returns the deleted item and true if found, zero value and false otherwise.
func (*PAvlTree[T]) Find ¶
Find searches for target in tree. Returns the item and true if found, zero value and false otherwise.
type PRbIter ¶
type PRbIter[T any] struct { // contains filtered or unexported fields }
func NewPRbIter ¶
type PRbTree ¶
type PRbTree[T any] struct { // contains filtered or unexported fields }
func NewPRbTree ¶
NewPRbTree creates a new Red-Black tree with parent pointers for cmp.Ordered types.
func NewPRbTreeFunc ¶
NewPRbTreeFunc creates a new Red-Black tree with parent pointers using a custom comparison function.
func (*PRbTree[T]) Delete ¶
Delete deletes item from tree. Returns the deleted item and true if found, zero value and false otherwise.
func (*PRbTree[T]) Find ¶
Find searches for target in tree. Returns the item and true if found, zero value and false otherwise.
type RbTree ¶
type RbTree[T any] struct { // contains filtered or unexported fields }
func NewRbTree ¶
NewRbTree creates a new Red-Black tree for cmp.Ordered types (int, string, float64, etc.)
func NewRbTreeFunc ¶
NewRbTreeFunc creates a new Red-Black tree with a custom comparison function.
func (*RbTree[T]) Delete ¶
Delete deletes item from tree. Returns the deleted item and true if found, zero value and false otherwise.
func (*RbTree[T]) Find ¶
Find searches for target in tree. Returns the item and true if found, zero value and false otherwise.