views:

28

answers:

2

Has anyone implemented a Set class in ActionScript? Specifically, a Set which is similar to Python's set implementation (unordered, unique, O(1) membership, etc).

I'd like to be able to iterate over it using for each, perform operations like union and intersection and get a list of all the contained items… Which would all be possible to implement using Dictionary and Proxy, but I'd rather not reimplement it if someone's already done the heavy lifting.

+1  A: 

This looks like a decent enough implementation.

Link to Collection class

sberry2A
Hhmm… It doesn't allow duplicates, but the membership is O(N), so it won't quite do for what I'm looking for. It's good to know about though - thanks.
David Wolever
+1  A: 

Way overkill, but polygonal_ds is a very optimized set of data structures you can use from AS3.

gregj
Ah, that's good to know about. Thanks.
David Wolever