LinkedList v1.0

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.



Details

Author
Adrian Statescu
Current version
v1.0
GitHub
thinkphp/LinkedList
Downloads
1126
Category
Utilities
Tags
Report
GitHub Issues

Releases


Dependencies

  • core/1.4.5: *

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:

  • http://en.wikipedia.org/wiki/Linked_list#Post_office_box_analogy
  • http://www.informit.com/store/product.aspx?isbn=0201350882

Discuss

A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.

Found a bug in this plugin? Please report it this repository's Github Issues.

blog comments powered by Disqus