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
You can use or take as an exmaple as3Commons linked list implementation. They provide very beautiful implementation with very good abstraction layer.
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);
}
来源:https://stackoverflow.com/questions/11874805/create-linked-list-in-as3