--this.size
return true
}
- let physicalShiftIndex = currentPhysicalIndex
+ let shiftPhysicalIndex = currentPhysicalIndex
for (let i = logicalIndex; i < this.size - 1; i++) {
- let nextPhysicalIndex = physicalShiftIndex + 1
+ let nextPhysicalIndex = shiftPhysicalIndex + 1
if (nextPhysicalIndex === this.capacity) {
nextPhysicalIndex = 0
}
- this.nodeArray[physicalShiftIndex] = this.nodeArray[nextPhysicalIndex]
- physicalShiftIndex = nextPhysicalIndex
+ this.nodeArray[shiftPhysicalIndex] = this.nodeArray[nextPhysicalIndex]
+ shiftPhysicalIndex = nextPhysicalIndex
}
- this.nodeArray[physicalShiftIndex] = undefined
+ this.nodeArray[shiftPhysicalIndex] = undefined
--this.size
return true
}
currentPhysicalIndex = 0
}
}
- let end = this.start + this.size
- if (end >= this.capacity) {
- end -= this.capacity
+ let endPhysicalIndex = this.start + this.size
+ if (endPhysicalIndex >= this.capacity) {
+ endPhysicalIndex -= this.capacity
}
if (insertionPhysicalIndex === -1) {
- insertionPhysicalIndex = end
+ insertionPhysicalIndex = endPhysicalIndex
} else {
- let toShiftIndex = end
- while (toShiftIndex !== insertionPhysicalIndex) {
- const previousIndex =
- toShiftIndex === 0 ? this.capacity - 1 : toShiftIndex - 1
- this.nodeArray[toShiftIndex] = this.nodeArray[previousIndex]
- toShiftIndex = previousIndex
+ let shiftPhysicalIndex = endPhysicalIndex
+ while (shiftPhysicalIndex !== insertionPhysicalIndex) {
+ const previousPhysicalIndex =
+ shiftPhysicalIndex === 0 ? this.capacity - 1 : shiftPhysicalIndex - 1
+ this.nodeArray[shiftPhysicalIndex] =
+ this.nodeArray[previousPhysicalIndex]
+ shiftPhysicalIndex = previousPhysicalIndex
}
}
this.nodeArray[insertionPhysicalIndex] = { data, priority }