c# matching fixed properties on in memory data
<p>Guys this is racking my brain</p>

<p>I have a <strong>slow</strong> implementation in Linq that I need to speed up.</p>

<p>I need the fastest possible way to compare a large set of readonly data in memory (200,000) rows.</p>

<p>Each row has a name and 10 integers representing properties on the name</p>

<pre><code>Brake   8 7 3 2 1 0 4 3 2
Skull   8 7 3 2 1 0 4 3 2
Napkin  3 0 5 3 2 1 3 1 0
</code></pre>

<p>Each item will never have more then 8 in any single property. So each value can fit nicely into a double </p>

<p>ex: </p>

<pre><code>Brake:873,210,432
</code></pre>

<p>Now my problem is I need to compare these values to a maximum number for each field</p>

<p>ie:</p>

<p>500,000,000 would return the first 2 and</p>

<p>000,001,000 would only return Napkin because the other 2 don't have at least 1 in the 4th position.</p>

<p>I'm open to any soltuion that is as <strong>fast</strong> as possible. There will be a lot of comparisons so speed is the only thing I'm worried about here.</p>

<p>My current implementation would be something like this:</p>

<pre><code>Items.Where(c =&gt; c.A &lt;= 5).Where(c =&gt; c.B &lt;= 0).Where(c =&gt; c.C &lt;= 0)
.Where(c =&gt; c.D &lt;= 0).Where(c =&gt; c.E &lt;= 0).Where(c =&gt; c.F &lt;= 0)
.Where(c =&gt; c.H &lt;= 0).Where(c =&gt; c.I &lt;= 0).Where(c =&gt; c.J &lt;= 0)
</code></pre>

<p>Or (they both run about the same speed)</p>

<pre><code>Items.Where(c =&gt; c.A &lt;= 5 &amp;&amp; c.B &lt;= 0 &amp;&amp; c.C &lt;= 0
 &amp;&amp; c.D &lt;= 0 &amp;&amp; c.E &lt;= 0 &amp;&amp; c.F &lt;= 0 &amp;&amp; c.H &lt;= 0
&amp;&amp; c.I &lt;= 0 &amp;&amp; c.J &lt;= 0)
</code></pre>
