1.0.2 • Published 8 years ago

string-DLL v1.0.2

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

Build Status

Coverage Status

String DLL

A simple doubly linked list storing string values written in node compliant ES6 with no dependencies.

Install

  npm install string-DLL

Variables

  // First element in the list
  head

  // Last element in the list
  tail

  // Size of the list
  size

Methods

  // Appends new node with key to tail of list
  add(key)

  // Removes node with the given key from list
  remove(key)

  // Insert new node with value of key after node with target key
  insert(key, target)

  // Returns the node object of the given key in the list
  getNode(key)

Basic usage

  var DLL = require('string-DLL');

  const list = new DLL();

  list.add('one');
  list.add('two');

  console.log(list.size) // 2
  console.log(list.head.key) // 'one'
  console.log(list.tail.key) // 'two'

  list.remove('two');

  console.log(list.size) // 1
  console.log(list.head.key) // 'one'
  console.log(list.tail.key) // 'one'