tucaz/LinkedList
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
I needed a linked list to use in Javascript and couldn't find one so I wrote a simple implementation of it. Not sure if it is the best way, but it works for me :) Using it: var ll = new LinkedList(); ll.add(1); ll.add(2); ll.add(3); for(var n = ll.head; n; n = n.getNext()) console.log('Value: '+ n.getValue() + ' | Previous: ' + (n.getPrevious() == null ? '' : n.getPrevious().getValue())); ll.insertAfter(3, 4); for(var n = ll.head; n; n = n.getNext()) console.log('Value: '+ n.getValue() + ' | Previous: ' + (n.getPrevious() == null ? '' : n.getPrevious().getValue())); ll.replace(1, 100); for(var n = ll.head; n; n = n.getNext()) console.log('Value: '+ n.getValue() + ' | Previous: ' + (n.getPrevious() == null ? '' : n.getPrevious().getValue()));
About
A simple implementation for double linked lists in Javascript
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published