Documentation
¶
Index ¶
- func MaxCombine(a, b int) int
- func MinCombine(a, b int) int
- func SumCombine(a, b int) int
- type AVLNode
- type AVLTree
- type BPlusNode
- type BPlusTree
- type BTree
- type BTreeNode
- type Color
- type IBinaryTree
- type RBNode
- type RadixNode
- type RadixTree
- type RedBlackTree
- type SegmentTree
- type SplayNode
- type SplayTree
- type TSTNode
- type TernarySearchTree
- func (tst *TernarySearchTree) Clear()
- func (tst *TernarySearchTree) Delete(key string) bool
- func (tst *TernarySearchTree) Insert(key string, value interface{})
- func (tst *TernarySearchTree) IsEmpty() bool
- func (tst *TernarySearchTree) Keys() []string
- func (tst *TernarySearchTree) Search(key string) (interface{}, bool)
- func (tst *TernarySearchTree) Size() int
- func (tst *TernarySearchTree) StartsWith(prefix string) []string
- type Trie
- type TrieNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaxCombine ¶
func MinCombine ¶
Types ¶
type AVLTree ¶
type AVLTree struct { Root *AVLNode // contains filtered or unexported fields }
AVLTree represents an AVL tree
func (*AVLTree) InOrderTraversal ¶
InOrderTraversal performs inorder traversal of the tree
type BPlusNode ¶ added in v1.1.0
type BPlusNode struct {
// contains filtered or unexported fields
}
BPlusNode represents a node in the B+ tree
type BPlusTree ¶ added in v1.1.0
type BPlusTree struct {
// contains filtered or unexported fields
}
BPlusTree represents a B+ tree
func NewBPlusTree ¶ added in v1.1.0
func NewBPlusTree() *BPlusTree
NewBPlusTree creates a new B+ tree
func (*BPlusTree) Clear ¶ added in v1.1.0
func (bt *BPlusTree) Clear()
Clear removes all keys from the tree
type BTree ¶
type BTree struct {
// contains filtered or unexported fields
}
BTree represents a B-tree
func (*BTree) GetInOrder ¶
GetInOrder returns all keys in the B-tree in sorted order
type BTreeNode ¶
type BTreeNode struct {
// contains filtered or unexported fields
}
BTreeNode represents a node in B-tree
type IBinaryTree ¶
type IBinaryTree interface { Insert(data int) Search(data int) Exists(data int) bool Delete(data int) Max() int Min() int Print(pType string) List(pType string) []int }
func BinaryTree ¶
func BinaryTree(data int) IBinaryTree
type RadixNode ¶ added in v1.1.0
type RadixNode struct {
// contains filtered or unexported fields
}
RadixNode represents a node in the Radix Tree
type RadixTree ¶ added in v1.1.0
type RadixTree struct {
// contains filtered or unexported fields
}
RadixTree represents a radix tree (compact trie) data structure
func NewRadixTree ¶ added in v1.1.0
func NewRadixTree() *RadixTree
NewRadixTree creates a new empty radix tree
func (*RadixTree) Clear ¶ added in v1.1.0
func (rt *RadixTree) Clear()
Clear removes all keys from the tree
type RedBlackTree ¶
type RedBlackTree struct { Root *RBNode NIL *RBNode // Sentinel node // contains filtered or unexported fields }
RedBlackTree represents a Red-Black tree
func NewRedBlackTree ¶
func NewRedBlackTree() *RedBlackTree
NewRedBlackTree creates a new Red-Black tree
func (*RedBlackTree) InOrderTraversal ¶
func (t *RedBlackTree) InOrderTraversal(result *[]int)
InOrderTraversal performs an inorder traversal of the tree
func (*RedBlackTree) Insert ¶
func (t *RedBlackTree) Insert(key int)
Insert adds a new key to the tree
func (*RedBlackTree) Search ¶
func (t *RedBlackTree) Search(key int) bool
Search looks for a key in the tree
type SegmentTree ¶
type SegmentTree struct {
// contains filtered or unexported fields
}
SegmentTree represents a segment tree data structure
func NewSegmentTree ¶
func NewSegmentTree(arr []int, combine func(int, int) int) *SegmentTree
NewSegmentTree creates a new segment tree from an array
func (*SegmentTree) GetArray ¶
func (st *SegmentTree) GetArray() []int
GetArray returns the current array
func (*SegmentTree) Query ¶
func (st *SegmentTree) Query(left int, right int) int
Query returns the result of the combine function over the range [left, right]
func (*SegmentTree) Update ¶
func (st *SegmentTree) Update(i int, val int)
Update updates the value at index i to val
type SplayNode ¶ added in v1.1.0
type SplayNode struct {
// contains filtered or unexported fields
}
Node represents a node in the Splay Tree
type SplayTree ¶ added in v1.1.0
type SplayTree struct {
// contains filtered or unexported fields
}
SplayTree represents a self-adjusting binary search tree
func NewSplayTree ¶ added in v1.1.0
func NewSplayTree() *SplayTree
NewSplayTree creates and returns a new Splay Tree
func (*SplayTree) Clear ¶ added in v1.1.0
func (st *SplayTree) Clear()
Clear removes all nodes from the tree
type TSTNode ¶ added in v1.1.0
type TSTNode struct {
// contains filtered or unexported fields
}
TSTNode represents a node in the Ternary Search Tree
type TernarySearchTree ¶ added in v1.1.0
type TernarySearchTree struct {
// contains filtered or unexported fields
}
TernarySearchTree represents a ternary search tree data structure
func NewTernarySearchTree ¶ added in v1.1.0
func NewTernarySearchTree() *TernarySearchTree
NewTernarySearchTree creates a new empty ternary search tree
func (*TernarySearchTree) Clear ¶ added in v1.1.0
func (tst *TernarySearchTree) Clear()
Clear removes all keys from the tree
func (*TernarySearchTree) Delete ¶ added in v1.1.0
func (tst *TernarySearchTree) Delete(key string) bool
Delete removes a key from the tree
func (*TernarySearchTree) Insert ¶ added in v1.1.0
func (tst *TernarySearchTree) Insert(key string, value interface{})
Insert adds a key-value pair to the tree
func (*TernarySearchTree) IsEmpty ¶ added in v1.1.0
func (tst *TernarySearchTree) IsEmpty() bool
IsEmpty returns true if the tree is empty
func (*TernarySearchTree) Keys ¶ added in v1.1.0
func (tst *TernarySearchTree) Keys() []string
Keys returns all keys in the tree
func (*TernarySearchTree) Search ¶ added in v1.1.0
func (tst *TernarySearchTree) Search(key string) (interface{}, bool)
Search finds a key in the tree and returns its value
func (*TernarySearchTree) Size ¶ added in v1.1.0
func (tst *TernarySearchTree) Size() int
Size returns the number of keys in the tree
func (*TernarySearchTree) StartsWith ¶ added in v1.1.0
func (tst *TernarySearchTree) StartsWith(prefix string) []string
StartsWith returns all strings in the tree that start with the given prefix
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie represents a Trie (prefix tree)
func (*Trie) GetAllWords ¶
GetAllWords returns all words stored in the trie
func (*Trie) GetWordsWithPrefix ¶
GetWordsWithPrefix returns all words that start with the given prefix
func (*Trie) StartsWith ¶
StartsWith returns true if there is any word in the trie that starts with the given prefix