Here's an example:

<cfscript>
        arTest = arraynew(3);
        arTest[1098][1][3] = '5/15/2003';
        arTest[2034][3][6]= '7/15/2003';
        arTest[156][2][5]= '4/15/2003';
</cfscript>

<cfoutput>
array length: #arraylen(arTest)#
</cfoutput>

<cfdump var="#arTest[156][2][5]#">
<cfdump var="#arTest[1098][1][3]#">
<cfdump var="#arTest#">


If you look at the dump of arTest, you will see thousand of empty array
cells.  Does CF store these empty array cells in memory?  I'm having an
interesting discussion with a colleague as to why this is a bad idea
because it's not very efficient.  Keep in mind this array will be 10s of
thousands of entries long.  

Would a structure containing the concatenated key be more efficient?

<cfscript>
        stTest = structnew();
        stTest['1098_1_3'] = '5/15/2003';
        stTest['2034_3_6'] = '7/15/2003';
        stTest['156_2_5'] = '4/15/2003';
</cfscript>

<cfdump var="#stTest#">



Thanks -

Tom Schreck
817-252-4900
[EMAIL PROTECTED]

I have not failed.  I've found 10,000 ways that won't work.

- Thomas Edison


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 28, 2003 10:53 AM
To: [EMAIL PROTECTED]
Subject: RE: structures vs arrays

Or extremely high traffic on a given page yea... Most of the time I
don't generally put a lot of thought into which is more (or less)
efficient -- I write what's easiest to implement and easiest to change
or expand on later. When I have a project that's having a problem
handling the load (which is fairly uncommon), then I look for tweaks to
make it more efficient. 


------ Original Message ------ 
From: Dan Blackman <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Aug 28, 2003 09:56 AM
Subject: RE: structures vs arrays

>It's also negligible unless you are working with hundereds of thousands
>of rows in MHO.  You are not going to see the difference until you are
>hitting a sizable recordset...
>
>My 2 c
>
>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
>Behalf Of S.Isaac Dealey
>Sent: Thursday, August 28, 2003 9:41 AM
>To: [EMAIL PROTECTED]
>Subject: Re: structures vs arrays
>
>
>> Which one is more efficient at retrieving data: structure
>> or an array?
>
>Depends what you're doing with it...
>
>A structure is faster at finding a key than it is to find a given
string
>within an array... i.e.
>
>idx = structkeyexists(mystruct,"blah")
>
>vs. something like this:
>
>idx = listfind(arraytolist(myarray),"blah")
>
>or worse
>
>idx = 0;
>for (x = 1; x lte arraylen(myarray); x = x + 1) {
>  if (myarray[x] is "blah") { idx = x; break; }
>}
>
>I believe arrays are slightly faster when looping over them, i.e.
>
><cfloop index="x" from="1"
>to="#arraylen(myarray)#"></cfloop>
>
>vs.
>
><cfloop item="x" collection="#mystruct#"></cfloop>
>
>and I'm pretty sure getting a single value from an array
>
>myarray[3]
>
>is faster than getting a single value from a structure
>
>mystruct["blue"]
>
>I hope that's helpful. :)
>
>s. isaac dealey                972-490-6624
>
>team macromedia volunteer
>http://www.macromedia.com/go/team
>
>chief architect, tapestry cms  http://products.turnkey.to
>
>onTap is open source           http://www.turnkey.to/ontap
>
>
>-----------------------------------------------
>To post, send email to [EMAIL PROTECTED]
>To unsubscribe:
>   Send UNSUBSCRIBE to [EMAIL PROTECTED]
>To subscribe / unsubscribe: http://www.dfwcfug.org
>
>-----------------------------------------------
>To post, send email to [EMAIL PROTECTED]
>To unsubscribe:
>   Send UNSUBSCRIBE to [EMAIL PROTECTED]
>To subscribe / unsubscribe: http://www.dfwcfug.org
                
                
                

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To unsubscribe: 
   Send UNSUBSCRIBE to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To unsubscribe:
   Send UNSUBSCRIBE to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

Reply via email to