Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adriano-di-giovanni/doubly-linked-list-js
A DoublyLinkedList JavaScript Universal Module
https://github.com/adriano-di-giovanni/doubly-linked-list-js
Last synced: 1 day ago
JSON representation
A DoublyLinkedList JavaScript Universal Module
- Host: GitHub
- URL: https://github.com/adriano-di-giovanni/doubly-linked-list-js
- Owner: adriano-di-giovanni
- License: mit
- Created: 2014-02-07T22:01:07.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-10-04T07:34:26.000Z (about 8 years ago)
- Last Synced: 2024-11-02T21:06:56.635Z (11 days ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# doubly-linked-list-js
A `DoublyLinkedList` Javascript Universal Module.
## Installation
You may install this package using `bower` or `npm`:
`bower install doubly-linked-list-js --save`
`npm install doubly-linked-list-js --save`
## Usage
### Node.js
```javascript
var
DoublyLinkedList = require('doubly-linked-list-js');var
list = new DoublyLinkedList();
```## API
* [`forge()`](#forge)
* [`forgeCircular()`](#forgeCircular)
* [`add(data)`](#add)
* [`forEach(iterator, fromData, context)`](#forEach)
* [`forEachReverse(iterator, fromData, context)`](#forEachReverse)
* `getAt(index)`
* `getFirst()`
* `getIndexOf(data)`
* `getLast()`
* `getRandom()`
* `getLastIndexOf(data)`
* `getLength()`
* `getNext(data)`
* `getPrevious(data)`
* `isCircular()`
* `isEmpty()`
* `makeCircular()`
* `makeLinear()`
* `removeAt(index)`
* `toArray()`
* `toString()````javascript
var
list = DoublyLinkedList.forge();
``````javascript
var
list = DoublyLinkedList.forgeCircular();
``````javascript
list
.add('a')
.add('b')
.add('c');
``````javascript
var
array = [];list.forEach(function (data) {
array.push(data);
}, 'b');console.log(array.toString()); // b,c
list
.makeCircular()
.forEach(function (data) {
array.push(data);
}, 'b');console.log(array.toString()); // b,c,a
``````javascript
var
array = [];list.forEachReverse(function (data) {
array.push(data);
}, 'b');console.log(array.toString()); // b,a
list
.makeCircular()
.forEachReverse(function (data) {
array.push(data);
}, 'b');console.log(array.toString()); // b,a,c
```