title: ColdFusion - What's an efficient way to search an array of structs?
body: <p>I have a semi-large (hundreds of records) 1-dimensional array in ColdFusion. Each item in the array is a struct with several properties. I want to search the array for a struct that has a specific "name" property. I know that for an array of string values I could use Java methods like so:</p>
  
  <pre><code>&lt;cfset arrayIndex = myArray.indexOf("WhatImLookingFor") + 1&gt;
  </code></pre>
  
  <p>...but that won't work for an array of structs. I also know I could brute-force it like this:</p>
  
  <pre><code>&lt;cfset arrayIndex = 0&gt;
  &lt;cfloop from="1" to="#ArrayLen(myArray)#" index="counter"&gt;
      &lt;cfif myArray[counter].name IS "WhatImLookingFor"&gt;
          &lt;cfset arrayIndex = counter&gt;
      &lt;/cfif&gt;
  &lt;/cfloop&gt;
  </code></pre>
  
  <p>...but I feel like there must be a more efficient way. Does anyone have a better solution than this? You can assume that the "name" property is present in every struct and there are no gaps or other objects in the array.</p>