mauriciosantos / Buckets-JS

A complete, fully tested and documented data structure library written in pure JavaScript.
MIT License
1.25k stars 112 forks source link

Does LinkedList expose the head node directly? #12

Closed mikehaas763 closed 9 years ago

mikehaas763 commented 9 years ago

All of the methods I see in the documentation return the element from the underlying array. This makes it impossible to do something like node.next to walk the linked list. I looked at the source for a minute, am I missing something?

mauriciosantos commented 9 years ago

you can't access the list nodes directly, but you can iterate through the list elements using the forEach method.

mikehaas763 commented 9 years ago

I see, thanks for the info. If you can't get access to the underlying nodes then quite frankly LinkedList is not a linked list. It's simply a glorified array backed by a linked list implementation. In and of itself though it is not a reusable linked list.

The reason I say this is because one of the main purposes of the linked list data structure is to be able to get to the next node via a direct reference rather than searching for it first.

Thanks for this library though I like several things in it!