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);
}