Efficiently copying a matrix of objects to a larger matrix of objects
<p>I'm writing a quadtree-like data structure which contains matrices of generic objects <code>T</code>. If four subnodes all contain defined matrices of <code>T</code>, I'm going to aggregate them into a single, larger matrix, then delete the subnodes. Is there a more efficient way to do this than looping through every reference and copying it over? Can I copy chunks of memory instead?</p>

<hr>

<p><strong>Example:</strong></p>

<pre><code>T[,] _leaf1 = new T[64,64];
T[,] _leaf2 = new T[64,64];
T[,] _leaf3 = new T[64,64];
T[,] _leaf4 = new T[64,64];

// Populate leafs

T[,] _root = new T[128,128];

CopyInto(ref _root, ref _leaf1, 64, 64);
CopyInto(ref _root, ref _leaf2, 0, 64);
CopyInto(ref _root, ref _leaf3, 0, 0);
CopyInto(ref _root, ref _leaf4, 64, 0);
</code></pre>
