"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Heap_1 = require("../Heap");
const assert_1 = require("../util/assert");
const heap = {
    value: 6,
    left: {
        value: 5,
        left: { value: 4 },
        right: { value: 3 },
    },
    right: {
        value: 2,
        left: { value: 1 },
        right: { value: 0 },
    },
};
const predicate = (a, b) => a >= b;
let _heap = (0, Heap_1.parentHeap)(heap, null);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 6,
    left: {
        value: 5,
        left: { value: 4 },
        right: { value: 3 },
    },
    right: {
        value: 2,
        left: { value: 1 },
        right: { value: 0 },
    },
});
assert_1.default.deepEqual((0, Heap_1.findInsertionPoint)(_heap).value, 4);
assert_1.default.deepEqual((0, Heap_1.findLastLeaf)(_heap).value, 0);
_heap = (0, Heap_1.addHeapNode)(_heap, { value: 7, parent: null, left: null, right: null }, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 7,
    left: {
        value: 6,
        left: {
            value: 5,
            left: {
                value: 4,
            },
        },
        right: {
            value: 3,
        },
    },
    right: {
        value: 2,
        left: {
            value: 1,
        },
        right: {
            value: 0,
        },
    },
});
assert_1.default.deepEqual((0, Heap_1.findLastLeaf)(_heap).value, 4);
assert_1.default.deepEqual((0, Heap_1.findInsertionPoint)(_heap).value, 5);
_heap = (0, Heap_1.removeHeapNode)(_heap, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 6,
    left: {
        value: 5,
        left: {
            value: 4,
        },
        right: {
            value: 3,
        },
    },
    right: {
        value: 2,
        left: {
            value: 1,
        },
        right: {
            value: 0,
        },
    },
});
_heap = (0, Heap_1.removeHeapNode)(_heap, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 5,
    left: {
        value: 4,
        left: {
            value: 0,
        },
        right: {
            value: 3,
        },
    },
    right: {
        value: 2,
        left: {
            value: 1,
        },
    },
});
_heap = (0, Heap_1.removeHeapNode)(_heap, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 4,
    left: {
        value: 3,
        left: {
            value: 0,
        },
        right: {
            value: 1,
        },
    },
    right: {
        value: 2,
    },
});
_heap = (0, Heap_1.addHeapNode)(_heap, { value: 7, parent: null }, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 7,
    left: {
        value: 3,
        left: {
            value: 0,
        },
        right: {
            value: 1,
        },
    },
    right: {
        value: 4,
        left: {
            value: 2,
        },
    },
});
_heap = (0, Heap_1.addHeapNode)(_heap, { value: 6, parent: null }, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 7,
    left: {
        value: 3,
        left: {
            value: 0,
        },
        right: {
            value: 1,
        },
    },
    right: {
        value: 6,
        left: {
            value: 2,
        },
        right: {
            value: 4,
        },
    },
});
assert_1.default.deepEqual((0, Heap_1.findLastLeaf)(_heap).value, 4);
assert_1.default.deepEqual((0, Heap_1.findInsertionPoint)(_heap).value, 0);
const _heap_2 = _heap.left.left;
_heap = (0, Heap_1.removeHeapNode)(_heap_2, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 7,
    left: {
        value: 4,
        left: {
            value: 3,
        },
        right: {
            value: 1,
        },
    },
    right: {
        value: 6,
        left: {
            value: 2,
        },
    },
});
_heap = (0, Heap_1.setHeapNode)(_heap, 5, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 6,
    left: {
        value: 4,
        left: {
            value: 3,
        },
        right: {
            value: 1,
        },
    },
    right: {
        value: 5,
        left: {
            value: 2,
        },
    },
});
let _heap_00 = _heap.left.left;
_heap = (0, Heap_1.setHeapNode)(_heap_00, 7, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 7,
    left: {
        value: 6,
        left: {
            value: 4,
        },
        right: {
            value: 1,
        },
    },
    right: {
        value: 5,
        left: {
            value: 2,
        },
    },
});
_heap = (0, Heap_1.addHeapNode)(_heap, { value: 7, parent: null }, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 7,
    left: {
        value: 6,
        left: {
            value: 4,
        },
        right: {
            value: 1,
        },
    },
    right: {
        value: 7,
        left: {
            value: 2,
        },
        right: {
            value: 5,
        },
    },
});
let _heap_10 = _heap.right.left;
_heap = (0, Heap_1.setHeapNode)(_heap_10, 7, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 7,
    left: {
        value: 6,
        left: {
            value: 4,
        },
        right: {
            value: 1,
        },
    },
    right: {
        value: 7,
        left: {
            value: 7,
        },
        right: {
            value: 5,
        },
    },
});
_heap = (0, Heap_1.removeHeapNode)(_heap, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 7,
    left: {
        value: 6,
        left: {
            value: 4,
        },
        right: {
            value: 1,
        },
    },
    right: {
        value: 7,
        left: {
            value: 5,
        },
    },
});
_heap_00 = _heap.left.left;
_heap = (0, Heap_1.removeHeapNode)(_heap_00, predicate);
assert_1.default.deepEqual((0, Heap_1.readHeap)(_heap), {
    value: 7,
    left: {
        value: 6,
        left: {
            value: 5,
        },
        right: {
            value: 1,
        },
    },
    right: {
        value: 7,
    },
});
assert_1.default.deepEqual((0, Heap_1.toSortedArray)(_heap, predicate), [7, 7, 6, 5, 1]);
const last_leaf = (0, Heap_1.findLastLeaf)(_heap);
assert_1.default.equal((0, Heap_1.findLastLeaf)(_heap).value, 1);
_heap = (0, Heap_1.removeHeapNode)(last_leaf, predicate);
// _heap = addHeapNode(_heap, { value: 7, parent: null }, predicate)
// assert.deepEqual(toSortedArray(_heap, predicate), [7, 7, 7, 6, 5, 1])
// _heap = addHeapNode(_heap, { value: 7, parent: null, children: [] }, predicate)
// assert.deepEqual(toArray(_heap), [7, 7, 6, 5, 4, 3, 2, 1, 0])
//# sourceMappingURL=Heap.js.map