Upgrade packages.

This commit is contained in:
Oleksii Trekhleb
2018-07-05 16:30:00 +03:00
parent 58640ee7b5
commit 17ad4dc4d1
14 changed files with 1695 additions and 542 deletions

View File

@@ -1,5 +1,5 @@
import DoublyLinkedListNode from './DoublyLinkedListNode';
import Comparator from './../../utils/comparator/Comparator';
import Comparator from '../../utils/comparator/Comparator';
export default class DoublyLinkedList {
/**

View File

@@ -1,4 +1,4 @@
import DoublyLinkedListNode from './../DoublyLinkedListNode';
import DoublyLinkedListNode from '../DoublyLinkedListNode';
describe('DoublyLinkedListNode', () => {
it('should create list node with value', () => {

View File

@@ -164,10 +164,10 @@ export default class MinHeap {
// If there is no parent or parent is less then node to delete then heapify down.
// Otherwise heapify up.
if (
leftChild !== null &&
(
parentItem === null ||
this.compare.lessThan(parentItem, this.heapContainer[indexToRemove])
leftChild !== null
&& (
parentItem === null
|| this.compare.lessThan(parentItem, this.heapContainer[indexToRemove])
)
) {
this.heapifyDown(indexToRemove);
@@ -208,8 +208,8 @@ export default class MinHeap {
let currentIndex = customStartIndex || this.heapContainer.length - 1;
while (
this.hasParent(currentIndex) &&
this.compare.lessThan(this.heapContainer[currentIndex], this.parent(currentIndex))
this.hasParent(currentIndex)
&& this.compare.lessThan(this.heapContainer[currentIndex], this.parent(currentIndex))
) {
this.swap(currentIndex, this.getParentIndex(currentIndex));
currentIndex = this.getParentIndex(currentIndex);
@@ -227,8 +227,8 @@ export default class MinHeap {
while (this.hasLeftChild(currentIndex)) {
if (
this.hasRightChild(currentIndex) &&
this.compare.lessThan(this.rightChild(currentIndex), this.leftChild(currentIndex))
this.hasRightChild(currentIndex)
&& this.compare.lessThan(this.rightChild(currentIndex), this.leftChild(currentIndex))
) {
nextIndex = this.getRightChildIndex(currentIndex);
} else {

View File

@@ -35,7 +35,9 @@ export default class BinarySearchTreeNode extends BinaryTreeNode {
this.setLeft(newNode);
return newNode;
} else if (this.nodeValueComparator.greaterThan(value, this.value)) {
}
if (this.nodeValueComparator.greaterThan(value, this.value)) {
// Insert to the right.
if (this.right) {
return this.right.insert(value);
@@ -63,7 +65,9 @@ export default class BinarySearchTreeNode extends BinaryTreeNode {
if (this.nodeValueComparator.lessThan(value, this.value) && this.left) {
// Check left nodes.
return this.left.find(value);
} else if (this.nodeValueComparator.greaterThan(value, this.value) && this.right) {
}
if (this.nodeValueComparator.greaterThan(value, this.value) && this.right) {
// Check right nodes.
return this.right.find(value);
}