Assaf Lavie
Assaf Lavie

Reputation: 76073

proper dictionary/map/tree/hash container in Flex

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.?

Upvotes: 8

Views: 4023

Answers (5)

Kaken Bok
Kaken Bok

Reputation: 3395

Don't miss the AS3Commons Collections Framework including several list, sets, maps and a tree. For a comparision of other libraries visit the article Why we need a collection framework in ActionScript.

Upvotes: 1

hasseg
hasseg

Reputation: 6807

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.

Upvotes: 8

Matt Guest
Matt Guest

Reputation: 1047

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/

Upvotes: 0

Christophe Herreman
Christophe Herreman

Reputation: 16085

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.

Upvotes: 1

David Hanak
David Hanak

Reputation: 10984

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.

Upvotes: 1

Related Questions