DoublyLinkedList.js
Class to create and handle doubly linked lists
Installation
npm install dbly-linked-list-js --save
Default node structure
data: "some data" // some data prev: null // node object or null next: null // node object or null
Usage
const DoublyLinkedList = ; const dll = ;dllhead; // the head nodedllcount; // the node count // adding nodeslist;list; // add multiple nodes at oncelist;list;// head node will be the one with the value "f" here // removing nodeslist; // returns the removed nodelist; // ..list; // remove nodes by its data valuelist;// limit the remove operations // list manipulationlist; // append the list by setting // the head node of the input list // as the next node of the last node from the current list list; // reverse the list list; // sort the list by passing a compare function // the example compare function is used by default // list utilslist; // return the last node in the list list; // return the node with the data value 2list; // return the node with the data value 3 // beginning at the node with the index 4 list; // return the node with the index 5list; // return the node with the index 6 // beginning at the node with the index 2 // iterate over the list by proving a callback functionlist; // optional argument to use as this in the iteration function // filter the list by providing a filter function // returns a new instance of the class // containing a list of nodes which passed the filter functionlist; // optional argument to use as this in the iteration function