Thanks Mark... "quite easily write yourself a quick binary search algorithm"
you make me chuckle... *chuckle* I'll get to that right after I whip up my CFC for splitting atoms. I'll have a look at the java thing. Are array's overly bursonsome? I am putting all my form field attributes (name, type, etc) in an array, which will likely end up being 3-dimensions. The information in the array is coming from 3 or 4 queries, so either I loop through the queries in the body of the page (I think kinda messy) or loop through my single array. I am not adding any looping to create the array. Cheers, Chad who thinks he used up his sigs for the day On 6/3/05, Mark Mandel <[EMAIL PROTECTED]> wrote: > Is the array sorted in any way? > > If it's completely un-sorted, you kinda don't have any options but to > do a O(n) search. > > If it is sorted, you could quite easily write yourself a quick binary > search algorithm, while it isn't the fastest searcher in the world, it > is better than looping through all the items. > > OR you could just be really lazy, and utilise the contains() Java > function off the myArray. > http://java.sun.com/j2se/1.4.2/docs/api/java/util/Vector.html#contains(java.lang.Object) > > Could be lots of fun since it's a 2d array. > > You may want to look into alternative data structures for your data if > it's a 2d array and you are finding it hard to manage. > > No reason at all you can't leverage Java Collections. > > Mark > > On 6/3/05, Chad Renando <[EMAIL PROTECTED]> wrote: > > 'morning all. > > > > What would be the best way to find a particular value in an array? > > Ideally, I would like to query my array to get a certain value where a > > condition is true, sort of like > > > > SELECT MyArray[1][5] > > FROM MyArray > > WHERE MyArray[1][2] = "Something" > > > > The altrnative is to loop through the array and grab the value on the > > way through, but I am thinking I will take a performance hit, > > particularly as I am doing this within a loop already... > > > > <cfloop index="i" from="1" to="#ArrayLen(MyArray)#"> > > <cfif MyArray[1][2] = "Something"><cfset MyValue=1></cfif> > > </cfloop> > > > > Cheers, > > > > Chad > > who uses band names like Rammstein in general conversation 'cause it > > just sounds cool > > -- > E: [EMAIL PROTECTED] > W: www.compoundtheory.com > ICQ: 3094740 > > --- > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] > To unsubscribe send a blank email to [EMAIL PROTECTED] > Aussie Macromedia Developers: http://lists.daemon.com.au/ > --- You are currently subscribed to cfaussie as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
