Skip to content

double linked list with methods similar to Array like push, pop...

License

Notifications You must be signed in to change notification settings

SaberLS/double-linked-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

double-linked-list

My attempt at creating double linked list with methods similar to Array like push, pop etc. ,implementing some basic sorting algorithms on created list and testing it with jest.

🛠 In this project I used

javascript jest nodejs

List methods

  • unshift(newHead): adds "newHead" node to the beginning of the list.
  • shift(): removes first node from the list, returns removed node.
  • push(newTail): adds "newTail" node to the end of the list.
  • pop(): removes last node from the list, returns removed node.
  • log(): returns a string with all nodes in a list.
  • findByIndex(searched): search through the list to find node with a given index, returns node with a given index.
  • indexOf(data): search through the list to find all Nodes with a given data, returns array with indexes of finded nodes.
  • isEmpty(): checks if a list is empty, returns true if is empty else false.
  • swap(x, y): swaps places of two given nodes.
  • isPartOfTheList(toCheck): checks if given node is part of the list, returns true if is part of the list else false.
  • forEach(func): takes function and executes it once for each list element. func(current, index) is called with two arguments current which is current node, index is index of current node in list.
  • remove(toRemove): removes given node from the list, returns removed node.
  • insertBefore(toInsert, next): takes two nodes toInsert node to insert to list, next node before which toInsert will be inserted.
  • insertAfter(toInsert, next): takes two nodes toInsert node to insert to list, previous node after which toInsert will be inserted.

Implemented sorting alghoritms

Run Locally

Clone the project

  git clone https://github.com/SaberLS/double-linked-list.git

Go to the project directory

  cd double-linked-list

Install dependencies

  yarn install

Running Tests

To run tests, run the following command

  yarn test

it runs all the tests and creates test coverage report at ./jest_html_reporters.html with use of jest-html-reporters

License

MIT

About

double linked list with methods similar to Array like push, pop...

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published