title: Fast search of objects in a collection
body: <p>I'm writing a C# application that should do a fast search inside of an array.
  I have a big collection that I'm loading from a file of objects of the following type</p>
  
  <pre><code>public class Info {
     public long Start { get; set; }
     public long End { get; set; }
     public string Info { get; set; }
     ...
  }
  </code></pre>
  
  <p>I need a fast way to find an object in that array where 
  Start &lt;= SomeValue &amp;&amp; End >= SomeValue</p>
  
  <p>Need only the first match.</p>
  
  <p>Please advice me what collection type should I use
  and may be a faster algorithm than just iterating through the objects.</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>"interval tree" structure was the best solution for me. It seems like > 30 times faster than iterating items in a collection until find and it took less than 1 ms to find items. Used this implementation <a href="https://github.com/mbuchetics/RangeTree" rel="nofollow">https://github.com/mbuchetics/RangeTree</a></p>
  
  <p>Thanks a lot guys</p>