1
0
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:
dudaodong
2022-03-01 11:04:38 +08:00
parent dd1cbf2ee3
commit bf7db0ded2
3 changed files with 64 additions and 1 deletions

View File

@@ -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 {