2

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

4
  • jacksondunstan.com/articles/548 Commented Aug 8, 2012 at 23:43
  • 2
    Did you try the term "as3 linked list" in your favorite search engine? Commented 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=179 Commented 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. Commented Aug 9, 2012 at 0:32

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.