0.3.0 • Published 9 years ago
struqt v0.3.0
Struqt
Struqt is a JavaScript (ES2015) library implementing commonly used data structures.
Its sole dependency is lodash.isequal, used for deep equality comparison of JavaScript objects.
Installation
Install via npm with the following command.
npm install --save struqt
Usage
API
SinglyLinkedList and DoublyLinkedList.
list.add(element)adds a newelement(of any type) as a node to the list.list.addAll(elements)inserts each members of anelementsarray into list.list.get(index)returns the node at the givenindex.list.remove(index)removes and return the node at a givenindex.list.removeFirstOccurrence(element)scans list from left to right and remove and returns the first node holding the givenelementas data; returns null if none was found.list.removeLastOccurrence(element)scans list from left to right and remove and returns the last node holding the givenelementas data; returns null if none was found.list.addAtIndex(index, element)adds a newelementin place of the givenindexin the list.list.addAllAtIndex(index, elements)inserts each members of anelementsarray into list, starting from the givenindexin it.list.contains(data)returns a boolean value stating whether or not the list contains a node holding the specifieddata(uses deep equality comparison).list.shift()returns and removes theheadof the list.list.pop()returns and removes thetailof the list.list.set(index, element)replaces the data held by the node at a givenìndexwith the givenelement.list.clone()returns a shallow copy of the list.list.toArray()returns an array of data compiled from the nodes in the list.list.clear()resets the list.Documentation
Documentation for the library can be generated using JSDoc. Run the following command to dump a small HTML-based documentation in a
docsdirectory.npm run doc
Tests
Run Mocha/Chai tests with the following command.
npm test
Contributing
TBA