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,IAC/C,EAAc,EAAY,KAE9B,OAAO,CACX,EAKA,EAAiB,UAAU,QAAU,WACjC,IAAI,EAAQ,IAAI,MAChB,GAAmB,GAAf,KAAK,OACL,OAAO,EAIX,IAFA,IAAI,EAAI,EACJ,EAAc,KAAK,MACD,MAAf,GAAuB,EAAI,IAC9B,EAAM,KAAK,GACX,EAAc,EAAY,KAC1B,IAEJ,OAAO,CACX,EAIA,EAAiB,UAAU,MAAQ,WAC/B,KAAK,IAAM,KACX,KAAK,MAAQ,KACb,KAAK,QAAU,CACnB,EACO,CACX,CA/NqC,GAgOrC,QAAQ,iBAAmB","file":"/npm/dl-doubly-linked-list-ts@1.0.3/doublyLinkedList.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/dl-doubly-linked-list-ts@1.0.3/doublyLinkedList.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n/**\r\n * Doubly Linked-List implementation class.\r\n */\r\nvar DoublyLinkedList = /** @class */ (function () {\r\n    function DoublyLinkedList() {\r\n        this._start = null;\r\n        this._end = null;\r\n        this._length = 0;\r\n    }\r\n    Object.defineProperty(DoublyLinkedList.prototype, \"start\", {\r\n        get: function () {\r\n            return this._start;\r\n        },\r\n        set: function (start) {\r\n            this._start = start;\r\n        },\r\n        enumerable: true,\r\n        configurable: true\r\n    });\r\n    Object.defineProperty(DoublyLinkedList.prototype, \"end\", {\r\n        get: function () {\r\n            return this._end;\r\n        },\r\n        set: function (end) {\r\n            this._end = end;\r\n        },\r\n        enumerable: true,\r\n        configurable: true\r\n    });\r\n    Object.defineProperty(DoublyLinkedList.prototype, \"length\", {\r\n        get: function () {\r\n            return this._length;\r\n        },\r\n        enumerable: true,\r\n        configurable: true\r\n    });\r\n    /**\r\n     * Returns true if the list is empty.\r\n     * @returns Returns true if list is empty or false otherwise.\r\n     */\r\n    DoublyLinkedList.prototype.isEmpty = function () {\r\n        return this.length == 0;\r\n    };\r\n    /**\r\n     * Inserts a node to the start of the list.\r\n     * @param node The node to be inserted to the list.\r\n     */\r\n    DoublyLinkedList.prototype.insertStart = function (node) {\r\n        if (this.isEmpty()) {\r\n            this.start = node;\r\n            this.end = node;\r\n        }\r\n        else {\r\n            node.next = this.start;\r\n            if (this.start != null) {\r\n                this.start.previous = node;\r\n            }\r\n            this.start = node;\r\n        }\r\n        this._length++;\r\n    };\r\n    /**\r\n     * Inserts a node to the end of the list.\r\n     * @param node The node to be inserted to the list.\r\n     */\r\n    DoublyLinkedList.prototype.insertEnd = function (node) {\r\n        if (this.isEmpty()) {\r\n            this.start = node;\r\n            this.end = node;\r\n        }\r\n        else {\r\n            node.previous = this.end;\r\n            if (this.end != null) {\r\n                this.end.next = node;\r\n            }\r\n            this.end = node;\r\n        }\r\n        this._length++;\r\n    };\r\n    /**\r\n     * Inserts a node at the specified index in the list.\r\n     * @param node The node to be inserted to the list.\r\n     * @param index The index to insert the node at. A value of -1 will insert the node to the end of the list.\r\n     */\r\n    DoublyLinkedList.prototype.insert = function (node, index) {\r\n        if (index == 0) {\r\n            this.insertStart(node);\r\n            return;\r\n        }\r\n        else if (index == -1) {\r\n            this.insertEnd(node);\r\n            return;\r\n        }\r\n        var currentNode = this.start;\r\n        var i = 0;\r\n        for (i = 0; i < index - 1 && currentNode != null; i++) {\r\n            currentNode = currentNode.next;\r\n        }\r\n        // Insertion not possible\r\n        if (i != index - 1 && currentNode == null) {\r\n            return;\r\n        }\r\n        if (currentNode != null) {\r\n            node.previous = currentNode;\r\n            node.next = currentNode.next;\r\n            if (currentNode.next != null) {\r\n                currentNode.next.previous = node;\r\n            }\r\n            else {\r\n                this.end = node;\r\n            }\r\n            currentNode.next = node;\r\n        }\r\n        this._length++;\r\n    };\r\n    /**\r\n     * Deletes the first node from the list.\r\n     */\r\n    DoublyLinkedList.prototype.deleteStart = function () {\r\n        if (this.isEmpty()) {\r\n            return;\r\n        }\r\n        if (this.start != null && this.start.next == null) {\r\n            this.start = null;\r\n            this.end = null;\r\n        }\r\n        else if (this.start != null) {\r\n            this.start = this.start.next;\r\n            if (this.start != null) {\r\n                this.start.previous = null;\r\n            }\r\n        }\r\n        this._length--;\r\n    };\r\n    /**\r\n     * Deletes the last node from the list.\r\n     */\r\n    DoublyLinkedList.prototype.deleteEnd = function () {\r\n        if (this.isEmpty()) {\r\n            return;\r\n        }\r\n        if (this.end != null && this.end.previous == null) {\r\n            this.start = null;\r\n            this.end = null;\r\n        }\r\n        else if (this.end != null) {\r\n            this.end = this.end.previous;\r\n            if (this.end != null) {\r\n                this.end.next = null;\r\n            }\r\n        }\r\n        this._length--;\r\n    };\r\n    /**\r\n     * Deletes a node from a specific index in the list. If the index is out of bounds, then no deletion will occur.\r\n     * @param index The index of the node to be deleted.\r\n     */\r\n    DoublyLinkedList.prototype.delete = function (index) {\r\n        if (this.isEmpty()) {\r\n            return;\r\n        }\r\n        if (index == 0) {\r\n            this.deleteStart();\r\n            return;\r\n        }\r\n        else if (index == -1) {\r\n            this.deleteEnd();\r\n            return;\r\n        }\r\n        var node = this.getNode(index);\r\n        if (node != null) {\r\n            if (node.next == null && node.previous != null) {\r\n                this.deleteEnd();\r\n            }\r\n            else if (node.previous == null && node.next != null) {\r\n                this.deleteStart();\r\n            }\r\n            else if (node.next != null && node.previous != null) {\r\n                node.previous.next = node.next;\r\n                node.next.previous = node.previous;\r\n                this._length--;\r\n            }\r\n        }\r\n    };\r\n    /**\r\n     * Retrieves a node from the specific index.\r\n     * @param index The index from which to retrieve the node.\r\n     * @returns Returns the node at the specific index or null if the index is out of bounds.\r\n     */\r\n    DoublyLinkedList.prototype.getNode = function (index) {\r\n        if (this.isEmpty() || index < 0) {\r\n            return null;\r\n        }\r\n        var currentNode = this.start;\r\n        for (var i = 1; i <= index && currentNode != null; i++) {\r\n            currentNode = currentNode.next;\r\n        }\r\n        return currentNode;\r\n    };\r\n    /**\r\n     * Returns an array of the nodes in the order of the list.\r\n     * @returns Array of nodes.\r\n     */\r\n    DoublyLinkedList.prototype.toArray = function () {\r\n        var array = new Array();\r\n        if (this.length == 0) {\r\n            return array;\r\n        }\r\n        var i = 0;\r\n        var currentNode = this.start;\r\n        while (currentNode != null && i < 12) {\r\n            array.push(currentNode);\r\n            currentNode = currentNode.next;\r\n            i++;\r\n        }\r\n        return array;\r\n    };\r\n    /**\r\n     * Clears the list and deletes all nodes.\r\n     */\r\n    DoublyLinkedList.prototype.clear = function () {\r\n        this.end = null;\r\n        this.start = null;\r\n        this._length = 0;\r\n    };\r\n    return DoublyLinkedList;\r\n}());\r\nexports.DoublyLinkedList = DoublyLinkedList;\r\n"]}