mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-09 23:22:28 +08:00
feat: add DeletetNode
This commit is contained in:
@@ -21,7 +21,7 @@ func NewBSTree[T any](rootData T) *BSTree[T] {
|
||||
return &BSTree[T]{root}
|
||||
}
|
||||
|
||||
// Insert data into BSTree
|
||||
// InsertNode insert data into BSTree
|
||||
func (t *BSTree[T]) InsertNode(data T, comparator lancetconstraints.Comparator) {
|
||||
root := t.root
|
||||
newNode := datastructure.NewTreeNode(data)
|
||||
@@ -32,6 +32,11 @@ func (t *BSTree[T]) InsertNode(data T, comparator lancetconstraints.Comparator)
|
||||
}
|
||||
}
|
||||
|
||||
// DeletetNode delete data into BSTree
|
||||
func (t *BSTree[T]) DeletetNode(data T, comparator lancetconstraints.Comparator) {
|
||||
deleteTreeNode(t.root, data, comparator)
|
||||
}
|
||||
|
||||
// NodeLevel get node level in BSTree
|
||||
func (t *BSTree[T]) NodeLevel(node *datastructure.TreeNode[T]) int {
|
||||
if node == nil {
|
||||
|
||||
Reference in New Issue
Block a user