If you can not tune a HashMap it will be worse than an ordinary array.
It will take more space and more processing time.

This will of course depend on the size and usage - it *may* be more
efficient with hashmaps. Do you really think we can generalize being it
worse all the time?

Keeping an array "ordered" to be able to do binary searches can
statistically cost a lot of "copying" at insertion time.
Binary searches may involves a lot more string comparison. In a binary
search comparing the "string hash" value is of no use to know if the value
is "greater" or "lower" (to decide for the next search direction). In
hashmaps, the lookup in the "chain" after the hash jump can, most of the
time, "skip" a string entry without even looking at the characters by
comparing the 32bit integer hashes.

About Arrays (this is more than slightly OT)  :-)

I still believe Arrays are implemented as associative arrays. But this is
just pure belief since I have no proof and it could easily change from one
version of the VM to the other.

var a:Array;
a[0] = 'abc';
a[123456789] = 'high index value';
a["this is text"] = 'non-integer index';

trace(a.length);   /// should output 123456790

Sidenote: I often use this "feature" of Arrays to make an "ordered
associative array" in one single object. This may look a bit like a hack -
but it is perfectly valid. I can both traverse the keys in a fixed custom
order and lookup one item with its key directly. Also you can retrieve
quickly how many items there are using "length". For example, when inserting
a new entry, I do something like:

 a[key] = value;
 a[a.length] = key;

I would really like to have insights into the flash VM implementation so I
could do better choices regarding maps and arrays.

regards,
B.

(--snip------rest of previous mail removed to keep it shorter-------snip---)
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to