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
-
jacksondunstan.com/articles/548Marty– Marty2012-08-08 23:43:23 +00:00Commented Aug 8, 2012 at 23:43
-
2Did you try the term "as3 linked list" in your favorite search engine?spender– spender2012-08-08 23:44:03 +00:00Commented Aug 8, 2012 at 23:44
-
Although discontinued, I used as3ds (actionscript 3 data structures) quite a lot when I was actionscripting. It's got many useful structures (including linked list). You can still download it from here: lab.polygonal.de/?page_id=179spender– spender2012-08-08 23:47:17 +00:00Commented Aug 8, 2012 at 23:47
-
Are you running into a performance problem using arrays? I couldn't imagine having a dataset in this scenario that an array wouldn't handle efficiently enough.invertedSpear– invertedSpear2012-08-09 00:32:34 +00:00Commented Aug 9, 2012 at 0:32
Add a comment
|
2 Answers
You can use or take as an exmaple as3Commons linked list implementation. They provide very beautiful implementation with very good abstraction layer.
Comments
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);
}
1 Comment
amacleod
Weirdly (to me, being used to cons lists), the
tail attribute of a LinkedList is a LinkedList node. My guess is that this is because AS3 tends to favor mutable data structures.