/** * Refactored implementation of LinkedList (part of javascript-algorithms project) by Github users: * mgechev, AndriiHeonia, Microfed and Jakeh (part of javascript-algorithms project - all project contributors * at repository website). * * Link to repository: https://github.com/mgechev/javascript-algorithms. */ /** * Linked list node. * * @class NodeStructure * @util */ declare class NodeStructure { /** * Data of the node. * * @member {object} */ data: unknown; /** * Next node. * * @member {NodeStructure} */ next: NodeStructure | null; /** * Previous node. * * @member {NodeStructure} */ prev: NodeStructure | null; /** * Initializes the node with the given data value. */ constructor(data: unknown); } /** * Linked list. * * @class LinkedList * @util */ declare class LinkedList { /** * The first node in the list, or null when the list is empty. */ first: NodeStructure | null; /** * The last node in the list, or null when the list is empty. */ last: NodeStructure | null; /** * Add data to the end of linked list. * * @param {object} data Data which should be added. * @returns {NodeStructure} Returns the node which has been added. */ push(data: Record): NodeStructure; /** * Add data to the beginning of linked list. * * @param {object} data Data which should be added. */ unshift(data: Record): void; /** * In order traversal of the linked list. * * @param {Function} callback Callback which should be executed on each node. */ inorder(callback: Function): void; /** * Remove data from the linked list. * * @param {object} data Data which should be removed. * @returns {boolean} Returns true if data has been removed. */ remove(data: Record): boolean; /** * Check if linked list contains cycle. * * @returns {boolean} Returns true if linked list contains cycle. */ hasCycle(): boolean; /** * Return last node from the linked list. * * @returns {NodeStructure} Last node. */ pop(): NodeStructure | null; /** * Return first node from the linked list. * * @returns {NodeStructure} First node. */ shift(): NodeStructure | null; /** * Reverses the linked list recursively. */ recursiveReverse(): void; /** * Reverses the linked list iteratively. */ reverse(): void; } export { NodeStructure }; export default LinkedList;