Create Linked List in AS3

2020-07-25 10:21发布

问题:

how can I create a linked list in actionScript 3.0? I have a project that I should get some integer numbers from the user and sort them by a tree algorithm for example heap-sort and show the tree in flash, I think I should use linked list to sort the data by tree algorithms. so anybody know how can I create a linked list which I can insert nodes, delete nodes and pass over the nodes, just like C++ linked list. Thanks. SA

回答1:

You can use or take as an exmaple as3Commons linked list implementation. They provide very beautiful implementation with very good abstraction layer.



回答2:

If you have access to the mx package, you could use mx.utils.LinkedList.

To construct the LinkedList you could repeatedly push or unshift items onto it.

var input:Array = getInput();
var myList:LinkedList = new LinkedList();
for each (var o:Object in input) {
    myList.push(o);
}