public void TestWithRenumber(int count) { List <int> correctList = new List <int>(); Random r = new Random(); for (int x = 0; x < count; x++) { correctList.Add(r.Next(10000000)); } CustomSortHelper <int> items = new CustomSortHelper <int>(correctList, (x, y) => x.CompareTo(y) < 0); correctList.Sort(); for (int i = 0; i < Math.Min(count, 100); i++) { int adder = r.Next(10000000); correctList[i] += adder; items[i] += adder; correctList.Sort(); items.SortAssumingIncreased(i); for (int x = 0; x < count; x++) { if (correctList[x] != items[x]) { throw new Exception(); } } } }
//------------------------------------------------------------- /// <summary> /// Will verify that the stream is in the proper order and remove any duplicates that were found. /// May be called after every single read, but better to be called /// when a ReadWhile function returns false. /// </summary> void VerifyArchiveStreamSortingOrder() { if (EOS) { return; } m_sortedArchiveStreams[0].UpdateCachedValue(); if (m_sortedArchiveStreams.Items.Length > 1) { //If list is no longer in order int compare = CompareStreams(m_sortedArchiveStreams[0], m_sortedArchiveStreams[1]); if (compare == 0 && m_sortedArchiveStreams[0].CacheIsValid) { //If a duplicate entry is found, advance the position of the duplicate entry RemoveDuplicatesFromList(); SetReadWhileUpperBoundsValue(); } if (compare > 0) { m_sortedArchiveStreams.SortAssumingIncreased(0); m_firstTable = m_sortedArchiveStreams[0]; m_firstTableScanner = m_firstTable.Scanner; SetReadWhileUpperBoundsValue(); } if (compare == 0 && !m_sortedArchiveStreams[0].CacheIsValid) { Dispose(); m_firstTable = null; m_firstTableScanner = null; } } else { if (!m_sortedArchiveStreams[0].CacheIsValid) { Dispose(); m_firstTable = null; m_firstTableScanner = null; } } }
public void TestWithRenumber(int count) { List<int> correctList = new List<int>(); Random r = new Random(); for (int x = 0; x < count; x++) { correctList.Add(r.Next(10000000)); } CustomSortHelper<int> items = new CustomSortHelper<int>(correctList, (x, y) => x.CompareTo(y) < 0); correctList.Sort(); for (int i = 0; i < Math.Min(count, 100); i++) { int adder = r.Next(10000000); correctList[i] += adder; items[i] += adder; correctList.Sort(); items.SortAssumingIncreased(i); for (int x = 0; x < count; x++) if (correctList[x] != items[x]) throw new Exception(); } }