Giter Club home page Giter Club logo

linkedlist.js's Introduction

LinkedList

A JavaScript Implementation of a Doubly Linked List.

ListNode(id, data)
  • id(id) get or set the id
  • data(data) get or set the data
  • hasNext() get whether or not node.next exists
  • hasPrev() get whether or not node.prev exists
LinkedList()
  • insertBefore(toInsertBefore, data) create a ListNode with data and insert it before the given node
  • addLast(data) (internal) create a ListNode with data and add it to the end of the list
  • add(data) alias for addLast
  • getFirst() return the first ListNode or null
  • getLast() return the last ListNode or null
  • size() return the size of the list
  • getFromFirst(index) (internal) get the ListNode at index by searching from the start
  • get(index) return the ListNode at the given index or throw Index Out Of Bounds
  • remove(node) remove and return the ListNode from the list
  • removeFirst() remove and return the first ListNode from the list
  • removeLast() return and return the last ListNode from the list
  • removeAll() remove all nodes from the list
  • each(iterator) iterate the list with iterator and call fn passing ListNode as a param for each
  • find(iterator) iterate the list with iterator, stop and return the node passed to iterator when the iterator returns truthy, otherwise return null
  • map(iterator) iterate the list with iterator, and push into an array all nodes that when passed to the iterator return truthy, then return the resulting array
  • push(data) alias for addLast
  • unshift(data) create a ListNode with data and insertBefore the first node in the list
  • pop() alias for removeLast
  • shift() alias for removeFirst

linkedlist.js's People

Watchers

Gerd Jungbluth avatar  avatar

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.