title: Implementing a sparse array in C# / fastest way to map integer to a specific bucket/range number
body: <p>My initial problem is that I need to implement a very fast, sparse array in C#. Original idea was to use a normal <code>Dictionary&lt;uint, TValue&gt;</code> and wrap it in my own class to only expose the <code>TValue</code> type parameter. Turns out this is pretty slow.</p>
  
  <p>So my next idea was to map each integer in the needed range (<code>UInt32.MinValue</code> to <code>UInt32.MaxValue</code>) to a bucket, of some size and use that. So I'm looking for a good way to map an unsigned integer X to a bucket Y, for example:</p>
  
  <p>Mapping the numbers 0-1023 to 8 different buckets holding 128 numbers each, 0-127, 128-255.</p>
  
  <p>But if someone has a better way of implementing a fast sparse array in C#, that would be most appreciated also.</p>