コード例 #1
0
        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();
                    }
                }
            }
        }
コード例 #2
0
        //-------------------------------------------------------------

        /// <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;
                }
            }
        }
コード例 #3
0
        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();

            }

        }