Beispiel #1
0
        static void FindRand(ICollectionComparable <int> list)
        {
            Random rand = new Random();

            for (uint i = 0; i < 1000; i++)
            {
                list.GetIndex(rand.Next());
            }
        }
Beispiel #2
0
        static void SetRand(ICollectionComparable <int> list)
        {
            Random rand = new Random();

            for (uint i = 0; i < 333; i++)
            {
                list.AddBack(rand.Next());
                list.AddFront(rand.Next());
                list.Insert(rand.Next(), i + 1);
            }
        }
Beispiel #3
0
        static string Test(ICollectionComparable <int> list)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            SetRand(list);
            stopwatch.Stop();
            string res = " Setting time: " + stopwatch.Elapsed;

            stopwatch.Reset();
            stopwatch.Start();
            FindRand(list);
            stopwatch.Stop();
            res += " Finding time: " + stopwatch.Elapsed + " " + list.ToString();
            return(res);
        }