graph-typed
Advanced tools
Comparing version
@@ -89,3 +89,3 @@ "use strict"; | ||
createNode(key, value, count) { | ||
return new AVLTreeMultiMapNode(key, value, count); | ||
return new AVLTreeMultiMapNode(key, this._isMapMode ? undefined : value, count); | ||
} | ||
@@ -92,0 +92,0 @@ /** |
@@ -78,3 +78,3 @@ "use strict"; | ||
createNode(key, value) { | ||
return new AVLTreeNode(key, value); | ||
return new AVLTreeNode(key, this._isMapMode ? undefined : value); | ||
} | ||
@@ -81,0 +81,0 @@ /** |
@@ -109,3 +109,3 @@ "use strict"; | ||
createNode(key, value) { | ||
return new BSTNode(key, value); | ||
return new BSTNode(key, this._isMapMode ? undefined : value); | ||
} | ||
@@ -132,6 +132,6 @@ /** | ||
keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) { | ||
const [node, tValue] = super.keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value); | ||
const [node, entryValue] = super.keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value); | ||
if (node === null) | ||
return [undefined, undefined]; | ||
return [node, tValue !== null && tValue !== void 0 ? tValue : value]; | ||
return [node, value !== null && value !== void 0 ? value : entryValue]; | ||
} | ||
@@ -204,2 +204,4 @@ /** | ||
this._replaceNode(current, newNode); | ||
if (this._isMapMode) | ||
this._setValue(current.key, newValue); | ||
return true; | ||
@@ -206,0 +208,0 @@ } |
@@ -77,3 +77,3 @@ "use strict"; | ||
createNode(key, value, color = 'BLACK') { | ||
return new RedBlackTreeNode(key, value, color); | ||
return new RedBlackTreeNode(key, this._isMapMode ? undefined : value, color); | ||
} | ||
@@ -181,4 +181,8 @@ /** | ||
} | ||
else | ||
return insertStatus === 'UPDATED'; | ||
if (insertStatus === 'UPDATED') { | ||
if (this._isMapMode) | ||
this._setValue(newNode.key, newValue); | ||
return true; | ||
} | ||
return false; | ||
} | ||
@@ -185,0 +189,0 @@ /** |
@@ -91,3 +91,3 @@ "use strict"; | ||
createNode(key, value, color = 'BLACK', count) { | ||
return new TreeMultiMapNode(key, value, count, color); | ||
return new TreeMultiMapNode(key, this._isMapMode ? undefined : value, count, color); | ||
} | ||
@@ -94,0 +94,0 @@ /** |
{ | ||
"name": "graph-typed", | ||
"version": "1.53.0", | ||
"version": "1.53.1", | ||
"description": "Graph. Javascript & Typescript Data Structure.", | ||
@@ -139,4 +139,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"data-structure-typed": "^1.53.0" | ||
"data-structure-typed": "^1.53.1" | ||
} | ||
} |
@@ -132,3 +132,3 @@ /** | ||
override createNode(key: K, value?: V, count?: number): NODE { | ||
return new AVLTreeMultiMapNode(key, value, count) as NODE; | ||
return new AVLTreeMultiMapNode(key, this._isMapMode ? undefined : value, count) as NODE; | ||
} | ||
@@ -135,0 +135,0 @@ |
@@ -102,3 +102,3 @@ /** | ||
override createNode(key: K, value?: V): NODE { | ||
return new AVLTreeNode<K, V, NODE>(key, value) as NODE; | ||
return new AVLTreeNode<K, V, NODE>(key, this._isMapMode ? undefined : value) as NODE; | ||
} | ||
@@ -105,0 +105,0 @@ |
@@ -144,3 +144,3 @@ /** | ||
override createNode(key: K, value?: V): NODE { | ||
return new BSTNode<K, V, NODE>(key, value) as NODE; | ||
return new BSTNode<K, V, NODE>(key, this._isMapMode ? undefined : value) as NODE; | ||
} | ||
@@ -178,5 +178,5 @@ | ||
): [OptNode<NODE>, V | undefined] { | ||
const [node, tValue] = super.keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value); | ||
const [node, entryValue] = super.keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value); | ||
if (node === null) return [undefined, undefined]; | ||
return [node, tValue ?? value]; | ||
return [node, value ?? entryValue]; | ||
} | ||
@@ -255,2 +255,3 @@ | ||
this._replaceNode(current, newNode); | ||
if (this._isMapMode) this._setValue(current.key, newValue); | ||
return true; | ||
@@ -257,0 +258,0 @@ } else if (this.comparator(current.key, newNode.key) > 0) { |
@@ -109,3 +109,3 @@ import type { | ||
override createNode(key: K, value?: V, color: RBTNColor = 'BLACK'): NODE { | ||
return new RedBlackTreeNode<K, V, NODE>(key, value, color) as NODE; | ||
return new RedBlackTreeNode<K, V, NODE>(key, this._isMapMode ? undefined : value, color) as NODE; | ||
} | ||
@@ -222,3 +222,8 @@ | ||
return true; | ||
} else return insertStatus === 'UPDATED'; | ||
} | ||
if (insertStatus === 'UPDATED') { | ||
if (this._isMapMode) this._setValue(newNode.key, newValue); | ||
return true; | ||
} | ||
return false; | ||
} | ||
@@ -225,0 +230,0 @@ |
@@ -127,3 +127,3 @@ /** | ||
override createNode(key: K, value?: V, color: RBTNColor = 'BLACK', count?: number): NODE { | ||
return new TreeMultiMapNode(key, value, count, color) as NODE; | ||
return new TreeMultiMapNode(key, this._isMapMode ? undefined : value, count, color) as NODE; | ||
} | ||
@@ -130,0 +130,0 @@ |
@@ -12,5 +12,5 @@ import { BinaryTree, BinaryTreeNode } from '../../../data-structures'; | ||
export type BinaryTreeOptions<K, V, R> = { | ||
iterationType?: IterationType; | ||
toEntryFn?: ToEntryFn<K, V, R>; | ||
isMapMode?: boolean; | ||
iterationType?: IterationType; | ||
toEntryFn?: ToEntryFn<K, V, R>; | ||
isMapMode?: boolean; | ||
} | ||
@@ -17,0 +17,0 @@ |
@@ -10,3 +10,3 @@ import { BST, BSTNode } from '../../../data-structures'; | ||
export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & { | ||
comparator?: Comparator<K> | ||
comparator?: Comparator<K> | ||
} | ||
@@ -13,0 +13,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2931143
0.03%40038
0.03%Updated