Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Linked List Implementation in MooTools
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Docs
Source
demo
README.md
package.yml

README.md

LinkedList

Linked List implementation in MooTools. A linked list is a set of items where each item is part of a node that also contains a link to a node. When our primary interest is to go through a collection of items sequentially, one by one, we can organize the items as a linked list: a basic data structure where each item contains the information that we need to get to the next item. The primary advantage of linked lists over arrays is that the links provide us with the capability to rearrange the items efficiently. This flexivility is gained at the expense of quick access to any arbitrary item in the list, because the only way to get to an item in the list is to follow links from the beginning.

Screenshot

How to use

First you must to include the JS files in the head of your HTML document.

    #HEAD
    <script src="http://www.google.com/jsapi?key=ABQIAAAA1XbMiDxx_BTCY2_FkPh06RRaGTYH6UMl8mADNa0YKuWNNa8VNxQEerTAUcfkyrr6OwBovxn7TDAH5Q"></script>
    <script type="text/javascript">google.load("mootools", "1.4.5");</script>
    <script type="text/javascript" src="LinkedList.js"></script>

Then

    #js
    var mylist = new LinkedList();
        mylist.insertAtHead("mootools");
        mylist.insertAtHead("jQuery");
        mylist.insertAtHead("dojo");
        mylist.insertAtHead("extjs");
        mylist.insertAtHead("yui");
        log(mylist.display())
        mylist.reverse();
        log(mylist.display()) 
        log(mylist.search(2))
        mylist.remove(2); 
        log(mylist.display())
        log(mylist.search(2))

Then

    #output:
    >yui,extjs,dojo,jQuery,mootools
    >mootools,jQuery,dojo,extjs,yui
    >dojo
    >mootools,jQuery,extjs,yui
    >extjs

References:

Something went wrong with that request. Please try again.