title: Fastest way to chop array in two pieces
body: <p>I have an array, say:</p>
  
  <pre><code>var arr1 = new [] { 1, 2, 3, 4, 5, 6 };
  </code></pre>
  
  <p>Now, when my array-size exceeds 5, I want to resize the current array to 3, and create a new array that contains the upper 3 values, so after this action:</p>
  
  <pre><code>arr1 = new [] { 1, 2, 3 };
  newArr = new [] { 4, 5, 6 };
  </code></pre>
  
  <p>What's the fastest way to do this? I guess I'll have to look into the unmanaged corner, but no clue.</p>
  
  <hr>
  
  <p>Some more info:</p>
  
  <ul>
  <li>The arrays have to be able to size up without large performance hits</li>
  <li>The arrays will only contain Int32's</li>
  <li>Purpose of the array is to group the numbers in my source array without having to sort the whole list</li>
  </ul>
  
  <p>In short: I want to split the following input array:</p>
  
  <pre><code>int[] arr = new int[] { 1, 3, 4, 29, 31, 33, 35, 36, 37 };
  </code></pre>
  
  <p>into</p>
  
  <pre><code>arr1 =  1, 3, 4
  arr2 =  29, 31, 33, 35, 36, 37
  </code></pre>
  
  <p>but because the ideal speed is reached with an array size of 3, <code>arr2</code> should be split into 2 evenly sized arrays.</p>
  
  <p><strong>Note</strong></p>
  
  <p>I know that an array's implementation in memory is quite naive (well, at least it is in C, where you can manipulate the count of items in the array so the array resizes). Also that there is a <code>memory move</code> function somewhere in the Win32 API. So I guess this would be the fastest:</p>
  
  <ol>
  <li>Change <code>arr1</code> so it only contains 3 items</li>
  <li>Create new array <code>arr2</code> with size 3</li>
  <li>Memmove the bytes that aren't in <code>arr1</code> anymore into <code>arr2</code></li>
  </ol>