* @param {number} [customStartIndex]
(customStartIndex)
| 221 | * @param {number} [customStartIndex] |
| 222 | */ |
| 223 | heapifyUp(customStartIndex) { |
| 224 | // Take the last element (last in array or the bottom left in a tree) |
| 225 | // in the heap container and lift it up until it is in the correct |
| 226 | // order with respect to its parent element. |
| 227 | let currentIndex = customStartIndex || this.heapContainer.length - 1; |
| 228 | |
| 229 | while ( |
| 230 | this.hasParent(currentIndex) |
| 231 | && !this.pairIsInCorrectOrder(this.parent(currentIndex), this.heapContainer[currentIndex]) |
| 232 | ) { |
| 233 | this.swap(currentIndex, this.getParentIndex(currentIndex)); |
| 234 | currentIndex = this.getParentIndex(currentIndex); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * @param {number} [customStartIndex] |
no test coverage detected