private RawTableItem[] GetSortedItems() { var list = new RawTableItem[tableItems.Count]; tableItems.CopyTo(list); Array.Sort(list); return(list); }
public RawTableInfo RemoveDuplicates() { // If no tables in duplicate then return if (tableItems.Count == 0) { return(new RawTableInfo()); } // Get the length of the first row set in the first table. We assume that // the row set length is identical across each table in the Vector. var elen = tableItems[0]; int len = elen.Rows.Count; if (len == 0) { return(new RawTableInfo(tableItems.ToArray())); } // Create a new row element to sort. var elems = new RawRowItem[len]; int width = tableItems.Count; // Create an array of RawTableElement so we can quickly access the data var rdup = new RawTableItem[width]; tableItems.CopyTo(rdup); // Run through the data building up a new RawTableElement[] array with // the information in every raw span. for (int i = 0; i < len; ++i) { var itemRows = new int[width]; for (int n = 0; n < width; ++n) { itemRows[n] = rdup[n].Rows[i]; } elems[i] = new RawRowItem(itemRows); } // Now 'elems' it an array of individual RawRowItem objects which // represent each individual row in the table. // Now sort and remove duplicates to make up a new set. Array.Sort(elems); var resultTables = new List <RawTableItem>(); // Make a new set of RawTableElement[] objects var items = rdup; // Set up the 'raw_info' vector with the new RawTableElement[] removing // any duplicate rows. for (int i = 0; i < width; ++i) { items[i].Rows.Clear(); } RawRowItem previous = null; for (int n = 0; n < len; ++n) { var current = elems[n]; // Check that the current element in the set is not a duplicate of the // previous. if (previous == null || previous.CompareTo(current) != 0) { for (int i = 0; i < width; ++i) { items[i].Rows.Add(current.RowValues[i]); } previous = current; } } for (int i = 0; i < width; ++i) { resultTables.Add(items[i]); } return(new RawTableInfo(resultTables.ToArray())); }