Skip to content

Commit

Permalink
fix: resolve issue where values were not properly deleted if the pare…
Browse files Browse the repository at this point in the history
…nt node was null
  • Loading branch information
izure1 committed Oct 18, 2024
1 parent 379fab8 commit 3ab3f68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serializable-bptree",
"version": "4.0.3",
"version": "4.0.4",
"description": "Store the B+tree flexibly, not only in-memory.",
"types": "./dist/types/index.d.ts",
"main": "./dist/cjs/index.cjs",
Expand Down
5 changes: 4 additions & 1 deletion src/BPTreeAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,11 @@ export class BPTreeAsync<K, V> extends BPTree<K, V> {
(node.keys.length < Math.ceil(this.order/2) && !node.leaf) ||
(node.values.length < Math.ceil((this.order-1)/2) && node.leaf)
) {
if (node.parent === null) {
return
}
let isPredecessor = false
let parentNode = await this.getNode(node.parent!) as BPTreeInternalNode<K, V>
let parentNode = await this.getNode(node.parent) as BPTreeInternalNode<K, V>
let prevNode: BPTreeInternalNode<K, V>|null = null
let nextNode: BPTreeInternalNode<K, V>|null = null
let prevValue: V|null = null
Expand Down
5 changes: 4 additions & 1 deletion src/BPTreeSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,11 @@ export class BPTreeSync<K, V> extends BPTree<K, V> {
(node.keys.length < Math.ceil(this.order/2) && !node.leaf) ||
(node.values.length < Math.ceil((this.order-1)/2) && node.leaf)
) {
if (node.parent === null) {
return
}
let isPredecessor = false
let parentNode = this.getNode(node.parent!) as BPTreeInternalNode<K, V>
let parentNode = this.getNode(node.parent) as BPTreeInternalNode<K, V>
let prevNode: BPTreeInternalNode<K, V>|null = null
let nextNode: BPTreeInternalNode<K, V>|null = null
let prevValue: V|null = null
Expand Down

0 comments on commit 3ab3f68

Please sign in to comment.