1.0.3 • Published 7 years ago

doubly-linked-list-typescript v1.0.3

Weekly downloads
2
License
ISC
Repository
-
Last release
7 years ago

doubly-linked-list-typescript

A doubly linked list written in typescript

Usage

To install the package run:

npm install doubly-linked-list-typescript

Then, to instantiate a new list in your project:

const List = require('doubly-linked-list-typescript').List;
const list = new List();

Push

Add an item to the end of the list.

list.push({ property: "value" });

Find Index

Returns the index in the list where the input data resides.

list.findIndex({ property: "value" });
//returns 0

Get Data at an Index

Returns data from the node at the specified index.

list.getData(0);
// returns { property: "value" }

Remove Item By Index

Removes the item in the list when given an index.

list.removeByIndex(0);

Remove Item by Data

Removes the item in the list when given data.

list.removeByData({ property: "value" });

To Array

list.toArray();
// transforms list to array type: [ { property: "value" } ]

Is Empty

Returns true if the list is empty, false if not

const list = new List();
list.isEmpty(); // true

list.push({ property: "value" });

list.isEmpty(); // false

To Do

  • benchmark and optimize performance
1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago