/// <summary>
 /// Reorder the database and index rows with the dictionary of row - location in <param name="rowsToMove">.
 /// </summary>
 /// <param name="rowsToMove">
 /// Dictionary of row - location.
 /// </param>
 private void RearrangeRowsAndIndex(Dictionary <Row, int> rowsToMove)
 {
     // Set the new sizes of both the index and database file.
     DataBaseStream.SetLength(((RowCount - DeletedRowCount) * ROW_BYTE_SIZE) + HEADER_BYTE_SIZE);
     IndexStream.SetLength((RowCount - DeletedRowCount) * INDEX_ROW_BYTE_SIZE);
     // Write each row to it's new location. Write each index keyvalue pair of primary key location to the index file.
     // Update the object index.
     foreach (KeyValuePair <Row, int> data in rowsToMove)
     {
         Index [data.Key.PrimaryKey] = data.Value;
         WriteRow(data.Key, data.Key.PrimaryKey, WriteType.RowMove);
         WriteIndexRow(data.Key.PrimaryKey, data.Value, WriteType.IndexRowMove);
     }
     // Update the row count accordingly and reassign deleted rows the value of 0. We've just compacted!
     RowCount               -= DeletedRowCount;
     DeletedRowCount         = 0;
     DataBaseStream.Position = HEADER_INFO_NUM_ROWS;
     // Write that to the database header.
     DataBaseWriter.Write(RowCount);
     DataBaseWriter.Write(DeletedRowCount);
 }