I would be a little surprised. There does not seem to be any way to control the hash parameters and every array would have a lot of wasted space for nothing and without any way to control the hash size and the percent utilization, you would not get a lot of advantage for the big arrays.

The Java HashMap defaults are pretty modest and would yield less than optimal performance with a big array. You can set the parameters if you have a big array and know a bit about the "randomness" of your keys to get fast lookups with a reasonable trade-off in wasted space

Perhaps someone who knows the Flash Player internals could tell for sure.

Ron


Bernard Poulin wrote:
mmm... Are you implying that ActionScript objects are not hashmaps?
I thought they were *all* hashmaps (even Arrays are hashmaps). Every method
call that you do involves at least one hash lookup.

B.

2006/5/10, Ron Wheeler <[EMAIL PROTECTED]>:

It appears that a HashMap is a Java class that uses a hash on the "key"
to store its keys and values.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html
This would speed up lookup if you have a large set of keys.
If you do not need the speed or do not have a large collection of keys
to store, an array object would seem to give the same functionality in
ActionScript.
This leaves the implementation of the array to Flash and it is likely a
simple structure that has to be searched sequentially (by the Flash VM)
to get the associated value.

It you really need a hashing array that can handle large numbers of
key/value pairs, you probably have to write one. This is an old concept
and you can likely find a few design ideas and probably some code if you
search for it.

If you are converting code and want to create a HashMap class that has
the same methods as HashMap in Java, you could fake the internal storage
technology with a simple Array. it would be faster for a small set of
values and would get a bit slower as the number of keys increased.
You could start with a dumb HashMap class and then make it a true
hashing data store later without having to rewrite your code.
HashMap was only added to Java in Java 1.1 and they lived without it
before then.

Ron

Joshua Graham wrote:
> Bit strange, but that works, thanks.
>
> Joshua
>
> On 10 May 2006, at 12:06, Lee McColl-Sylvester wrote:
>
>> Well, in AS2, it's called an object ;)
>>
>> Lee
>>
>>
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Joshua
>> Graham
>> Sent: 10 May 2006 11:19
>> To: flashcoders@chattyfig.figleaf.com
>> Subject: [Flashcoders] HashMap?
>>
>> Is there an AS3 equivalent of the java HashMap?
>>
>> Basically, I just need the ability to set key/value pairs quickly/
>> easily.
>> _______________________________________________
>> 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
>> _______________________________________________
>> 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
>>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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
_______________________________________________
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

_______________________________________________
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



_______________________________________________
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