示例#1
0
 public override void PushBack(object obj)
 {
     lock (root)
     {
         deque.PushBack(obj);
     }
 }
示例#2
0
        private static void PopulateDequePushBack(Deque deque)
        {
            deque.Clear();

            for(int i = 0; i < ElementCount; i++)
            {
                deque.PushBack(i);
            }

            Debug.Assert(deque.Count == ElementCount);

            int j = 0;

            foreach(int i in deque)
            {
                Debug.Assert(i == j);
                j++;
            }
        }
示例#3
0
        private static void TestEnumerator(Deque deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

            IEnumerator e = deque.GetEnumerator();

            try
            {
                object obj = e.Current;

                Debug.Fail("Exception failed");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                foreach(object obj in deque)
                {
                    Debug.Assert(e.MoveNext());
                }

                Debug.Assert(!e.MoveNext());

                object o = e.Current;

                Debug.Fail("Exception failed");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                e.Reset();

                foreach(object obj in deque)
                {
                    Debug.Assert(e.MoveNext());
                }

                Debug.Assert(!e.MoveNext());

                object o = e.Current;

                Debug.Fail("Exception failed");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                deque.PushBack(deque.Count);

                e.Reset();

                Debug.Fail("Exception failed");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                e.MoveNext();

                Debug.Fail("Exception failed");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }