Git Product home page Git Product logo

ds-sll's Introduction

Build Status Shippable CI

Install

via npm

npm install ds-sll

via git

git clone https://github.com/scriptnull/ds-sll.git

Usage

var ds = require('ds-sll')
 , LinkedList = ds.LinkedList
 , Node = ds.Node ;

Node

Nodes are elementary blocks of Linked List. To maintain data within Linked List, use Node objects as containers. Nodes have data and a pointer to next node.

Creating a node

var numberNode = new Node(1);
var stringNode = new Node('yo');
var objectNode = new Node({ foo : 'bar'});

Properties

var node = new Node(1);
console.log(node.data);  //1 - data of node
console.log(node.next);  //null - next pointer

Methods

  • setNext(node)
  • getNext()

Linked List

Singly Linked Lists are collection of Node objects having only next pointer.

Creating a Linked List

var ll = new LinkedList();

Properties

var ll = new LinkedList();
console.log(ll.length); // 0 - length of linked list
console.log(ll.head);   // null - head of the linked list

Methods

  • insertAtHead(node)
  • insertAtTail(node)
  • insertAtPosition(node,position)
  • deleteAtHead()
  • deleteAtTail()
  • deleteAtPosition(position)
  • getDataAtPosition(position)
  • findPositionByData(data)

Contributing

Any kind of contribution is welcomed. If you are adding new features , be sure to write the required tests for it.

Tests

Tests are written with Mocha + inbuilt Node.js assert library. Initail commit has about 30+ tests. If you feel ds-sll is going wrong somewhere. You could report it in issues or better submit a pull request by describing the case in a test suite. You can track the build status from travis-ci

License

ds-sll's People

Contributors

scriptnull avatar shubhankit92 avatar

Watchers

James Cloos avatar

Forkers

riturajcse

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.