Mailing List
Home
Forum Home
Flash Pro
Subjects
Subject: RE: Firework Effect
Web Service Results
Flash Interface with 10mb xml file
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash MX 2004 Sucks
Reading and displaying RSS feeds in Flash MX
Flash and QuickTime VR
Textfield prototype question
XML to Object help
Order of events per frame
MX2004 Dataset itemClassName
memory management removeMovieClip /
Event Dispatcher between classes
Help: MX 2004 How to script a print button to print the entire sli
ScrollPane component doesn 't auto update
setInterval bug identified and fixed
setInterval bug identified and fixed
Listener Object 's best practice
 
RE: AS 2.0 optimising..

RE: AS 2.0 optimising..

2004-03-16       - By Metanet Software

 Back
Reply:     1     2     3     4     5     6     7     8  

hi,
i just wanted to mention something: i agree with the "usage" qualifier, i
guess i was specifically referring to looking up a single value.

two comments:

(1)
using the object as a hashlist to avoid having to loop through a list
searching for a match has nothing to do with object-vs-array, it's simply
using the abstract data type most suitable for the job.


(2)
"I am guessing that they are using a dictionary internally, a hashtable
where values
are indexed as strings [String name, Object value]."
i'm almost positive that arrays are implemented as double-linked-lists
internally, which accoutns for the O(n) lookups. a hashtable would really
such for things like shifting/etc...


anyway, i just wanted to be a bit more specific in case the info helps
anyone; a couple months ago i ran some tests, i could probably find the code
if anyone case, but basically i was comparing arrays to objects in two
cases; i used integer "keys" for the object, i.e
list = new Object();
list[0] = "jimmy";

-looking up a single element at a known index:
objects took constant time, arrays took linear time (based on the length of
the array).
so, objects are MUCH faster if you have larage lists and you frequently
lookup a single value (for instance, any kind of look-up-table would be
faster if implemented as an object instead of an array)

-iterating over all elements (using a for..in loop)
this took approx. the same amount of time for both array and objects

even if you wanted to only iterate over a subsection of the list, as long as
you use integers as the hash-keys, you can use objects instead of arrays..

so, what am i missing? because it seems to me that arrays are sort of
useless...

raigan

__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
MSN Premium includes powerful parental controls and get 2 months FREE*  
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http:/
/hotmail.com/enca&HL=Market_MSNIS_Taglines


=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:107117
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)