Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coming from C++ to AS3 : what are fundamental AS3 data structures classes?

We are porting out game from C++ to web; the game make extensive use of STL.

Can you provide short comparison chart (and if possible, a bit of code samples for basic operations like insertion/deletion/searching and (where applicable) equal_range/binary_search) for the classes what are equivalents to the following STL containers :

std::vector
std::set
std::map
std::list
stdext::hash_map

?

Thanks a lot for your time!

UPD: wow, it seems we do not have everything we needhere :(

Can anyone point to some industry standard algorithms library for AS3 programs (like boost in C++)? I can not believe people can write non-trivial software without balanced binary search trees (std::set std::map)!

like image 268
Alexander K. Avatar asked Jul 24 '11 10:07

Alexander K.


2 Answers

The choices of data structures are significantly more limited in as3. You have:

  • Array or Vector.<*> which stores a list of values and can be added to after construction
  • Dictionary (hash_map) which stores key/value pairs

maps and sets aren't really supported as there's no way to override object equality. As for binary search, most search operations take a predicate function for you to override equality for that search.

Edit: As far as common algorithm and utility libraries, I'd take a look at as3commons

like image 65
Richard Szalay Avatar answered Nov 11 '22 17:11

Richard Szalay


Maybe this library will fit your needs.

like image 32
OXMO456 Avatar answered Nov 11 '22 18:11

OXMO456