Skip to content

tucaz/LinkedList

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

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

No packages published