data-structure-typed 1.45.1 → 1.45.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3773,18 +3773,16 @@ var dataStructureTyped = (() => {
3773
3773
  * @param index - The index of the newly added element.
3774
3774
  */
3775
3775
  bubbleUp(index) {
3776
- const element = this.nodes[index];
3776
+ const item = this.nodes[index];
3777
3777
  while (index > 0) {
3778
- const parentIndex = Math.floor((index - 1) / 2);
3779
- const parent = this.nodes[parentIndex];
3780
- if (this.comparator(element, parent) < 0) {
3781
- this.nodes[index] = parent;
3782
- this.nodes[parentIndex] = element;
3783
- index = parentIndex;
3784
- } else {
3778
+ const parent = index - 1 >> 1;
3779
+ const parentItem = this.nodes[parent];
3780
+ if (this.comparator(parentItem, item) <= 0)
3785
3781
  break;
3786
- }
3782
+ this.nodes[index] = parentItem;
3783
+ index = parent;
3787
3784
  }
3785
+ this.nodes[index] = item;
3788
3786
  }
3789
3787
  /**
3790
3788
  * Time Complexity: O(log n)
@@ -3798,8 +3796,8 @@ var dataStructureTyped = (() => {
3798
3796
  * @param index - The index from which to start sinking.
3799
3797
  */
3800
3798
  sinkDown(index) {
3801
- const leftChildIndex = 2 * index + 1;
3802
- const rightChildIndex = 2 * index + 2;
3799
+ const leftChildIndex = index << 1 | 1;
3800
+ const rightChildIndex = leftChildIndex + 1;
3803
3801
  const length = this.nodes.length;
3804
3802
  let targetIndex = index;
3805
3803
  if (leftChildIndex < length && this.comparator(this.nodes[leftChildIndex], this.nodes[targetIndex]) < 0) {