undirected-graph-typed
Advanced tools
Comparing version 1.45.1 to 1.45.2
@@ -274,15 +274,24 @@ "use strict"; | ||
bubbleUp(index) { | ||
const element = this.nodes[index]; | ||
// const element = this.nodes[index]; | ||
// while (index > 0) { | ||
// const parentIndex = (index - 1) >> 1; | ||
// const parent = this.nodes[parentIndex]; | ||
// if (this.comparator(element, parent) < 0) { | ||
// this.nodes[index] = parent; | ||
// this.nodes[parentIndex] = element; | ||
// index = parentIndex; | ||
// } else { | ||
// break; | ||
// } | ||
// } | ||
const item = this.nodes[index]; | ||
while (index > 0) { | ||
const parentIndex = Math.floor((index - 1) / 2); | ||
const parent = this.nodes[parentIndex]; | ||
if (this.comparator(element, parent) < 0) { | ||
this.nodes[index] = parent; | ||
this.nodes[parentIndex] = element; | ||
index = parentIndex; | ||
} | ||
else { | ||
const parent = (index - 1) >> 1; | ||
const parentItem = this.nodes[parent]; | ||
if (this.comparator(parentItem, item) <= 0) | ||
break; | ||
} | ||
this.nodes[index] = parentItem; | ||
index = parent; | ||
} | ||
this.nodes[index] = item; | ||
} | ||
@@ -301,4 +310,4 @@ /** | ||
sinkDown(index) { | ||
const leftChildIndex = 2 * index + 1; | ||
const rightChildIndex = 2 * index + 2; | ||
const leftChildIndex = index << 1 | 1; | ||
const rightChildIndex = leftChildIndex + 1; | ||
const length = this.nodes.length; | ||
@@ -305,0 +314,0 @@ let targetIndex = index; |
{ | ||
"name": "undirected-graph-typed", | ||
"version": "1.45.1", | ||
"version": "1.45.2", | ||
"description": "Undirected Graph. Javascript & Typescript Data Structure.", | ||
@@ -148,4 +148,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"data-structure-typed": "^1.45.0" | ||
"data-structure-typed": "^1.45.2" | ||
} | ||
} |
@@ -308,14 +308,24 @@ /** | ||
protected bubbleUp(index: number): void { | ||
const element = this.nodes[index]; | ||
// const element = this.nodes[index]; | ||
// while (index > 0) { | ||
// const parentIndex = (index - 1) >> 1; | ||
// const parent = this.nodes[parentIndex]; | ||
// if (this.comparator(element, parent) < 0) { | ||
// this.nodes[index] = parent; | ||
// this.nodes[parentIndex] = element; | ||
// index = parentIndex; | ||
// } else { | ||
// break; | ||
// } | ||
// } | ||
const item = this.nodes[index]; | ||
while (index > 0) { | ||
const parentIndex = Math.floor((index - 1) / 2); | ||
const parent = this.nodes[parentIndex]; | ||
if (this.comparator(element, parent) < 0) { | ||
this.nodes[index] = parent; | ||
this.nodes[parentIndex] = element; | ||
index = parentIndex; | ||
} else { | ||
break; | ||
} | ||
const parent = (index - 1) >> 1; | ||
const parentItem = this.nodes[parent]; | ||
if (this.comparator(parentItem, item) <= 0) break; | ||
this.nodes[index] = parentItem; | ||
index = parent; | ||
} | ||
this.nodes[index] = item; | ||
} | ||
@@ -336,4 +346,4 @@ | ||
protected sinkDown(index: number): void { | ||
const leftChildIndex = 2 * index + 1; | ||
const rightChildIndex = 2 * index + 2; | ||
const leftChildIndex = index << 1 | 1; | ||
const rightChildIndex = leftChildIndex + 1; | ||
const length = this.nodes.length; | ||
@@ -340,0 +350,0 @@ let targetIndex = index; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1715803
32148
Updateddata-structure-typed@^1.45.2