views:

2000

answers:

4

I'm getting increasingly frustrated with Flex's Dictionary (which is really just an array with string indices).

Trivial things seem not to be possible, like getting the last element, or even iterating over the sorted container according to keys (the order seems to be arbitrary), and the sort functions seem to make a mess of everything if given an array with string indices.

Is there a better, more complete container library for Flex? Something with arrays, lists, queues, maps, multimaps, hashmaps, etc.?

+1  A: 

I don't know of a collection data type library for ActionScript 3/Flex but I would surely appreciate it.

We do have some extra collections in the Spring ActionScript framework though. We also have a bunch of utility methods to work with existing data types. Check the sources at https://fisheye.springframework.org/browse/se-springactionscript-as/spring-actionscript/trunk/core/src/main/actionscript/org/springextensions/actionscript/collections and https://fisheye.springframework.org/browse/se-springactionscript-as/spring-actionscript/trunk/core/src/main/actionscript/org/springextensions/actionscript/utils

I do want to point out that a Dictionary is not just an array with string indices. That would be the definition of an Object in ActionScript. The Dictionary can hold complex types as keys and not just strings, which is a big difference. It also uses strict equality (===) for key comparison.

Christophe Herreman
Thanks for the link. But some of these utility functions aren't exactly what I'm looking for. e.g. the implementation of containsKey (for Dictionary) does a O(n) iteration... hardly optimal. I'm afraid these are no substitute for proper containers.
Assaf Lavie
+1  A: 

Although it's not a complete container library, there is a HashSet implementation for AS at 3 lb Monkey Brain. I have been using it for some time without any complaints.

David Hanak
+4  A: 

The as3ds project has a bunch of collections classes for AS3. Haven't used them myself but they look very capable (and I might add, focused on performance). Uses the MIT license.

Maashaack has some collections classes as well. They use MPL 1.1/GPL 2.0/LGPL 2.1.

hasseg
The link to as3ds is broken. http://lab.polygonal.de/ds/ appears to be the same project.
Pieter Kuijpers
A: 

Polygonal Labs has a data structures library I've used in the past. It's geared towards game development, which really just means it's super optimized. It includes:

Multidimensional Array, Queue, Stack, Hash Table, Tree, Binary Tree, Binary Search Tree, Linked List, Heap, Graph, Bit Vector

They have an iterator pattern implemented on all of the classes that will be really familiar if you've done and Java development and easy to learn if you haven't.

Check out their site for a full description: http://lab.polygonal.de/ds/

Here's the library on google code: http://code.google.com/p/as3ds/

Matt Guest