Smart LinkedList
This repository have codes for node module "smart-ll" aka "Smart linked-list".
Installation
npm install smart-ll --save
Features
- Simplest yet powerful implementation of Linked-List data structure.
- Focus on high performance
- Additional features as "reverse list"
- Super-high test coverage
Basic Usage
var smartll = ; //this will intialize a new LinkedList Object and assign it to var linkedListvar linkedList = smartll;
List Node Structure
List will be form in following node format
var node = value : '<value>' next : <next-node>
Method Description
insert(value)
This function will insert any data to end of the list.
var smartll = ; var linkedList = smartll;linkedList;linkedList;linkedList;linkedList;
setNodeAtIndex(index {integer}, value)
This function will insert any data at specific index of the list.
var smartll = ; var linkedList = smartll;linkedList;linkedList;linkedList;linkedList;
getNodeAtIndex(index {integer})
This function will return node (refer node structure above) at specific index of the list.
linkedList;
getSize()
This function will return current size of the list.
linkedList;
getFirstNode()
This function will return first node of the list.
linkedList;
getLastNode()
This function will return last node of the list.
linkedList;
removeNodeAtIndex(index {integer})
This function will delete node at specific index of the list.
var smartll = ;var linkedList = smartll;linkedList; linkedList; console //it'll print zero as inserted node is removed.
reverseList()
This function will reverse the list.
var smartll = ;var linkedList = smartll;linkedList;linkedList;linkedList;linkedList; //it will completely reverse above list.linkedList;
printList
This function will print all nodes's values of the list over console.
linkedList;
please refer spec folder for jasmine tests.