Documentation
¶
Index ¶
- type Comparator
- type Node
- type Tree
- func (t *Tree[Key, Value]) Erase(key Key) bool
- func (t *Tree[Key, Value]) Get(key Key) (*Node[Key, Value], bool)
- func (t *Tree[Key, Value]) Index(rank int) (*Node[Key, Value], bool)
- func (t *Tree[Key, Value]) Insert(key Key, val Value) bool
- func (t *Tree[Key, Value]) Rank(key Key) int
- func (t *Tree[Key, Value]) Set(key Key, val Value)
- func (t *Tree[Key, Value]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node[Key any, Value any] struct { Key Key Val Value // contains filtered or unexported fields }
Node : node for AVL tree
type Tree ¶
Tree : AVL tree
func NewTree ¶
func NewTree[Key any, Value any](comp Comparator[Key]) *Tree[Key, Value]
NewTree creates a new AVL tree
func NewTreeOrdered ¶
func NewTreeOrdered[Key constraints.Ordered, Value any]() *Tree[Key, Value]
NewTree creates a new AVL tree for comparable key types
func (*Tree[Key, Value]) Erase ¶
Erase erases the node whose key is 'key' If the key is not found, it returns false.
func (*Tree[Key, Value]) Get ¶
Get returns the node whose key is 'key' and true. If the key is not found, it returns nil and false.
func (*Tree[Key, Value]) Index ¶
Index returns the node whose key is 'rank' th and true. If the key is not found, it returns nil and false.
func (*Tree[Key, Value]) Insert ¶
Insert adds a new node with 'key' and 'val' if a node with the key isn't found. Insert do nothing if a node with the key is found.
func (*Tree[Key, Value]) Rank ¶
Rank returns the index of the node whose key is 'key'. If the key is not found, it returns -1.