Exemplo n.º 1
0
 public override IEnumerator <T> GetEnumerator()
 {
     lock (root)
     {
         return(deque.GetEnumerator());
     }
 }
Exemplo n.º 2
0
        private static void TestClone(Deque <int> deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

            Deque <int> deque2 = (Deque <int>)deque.Clone();

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

            IEnumerator <int> d2 = deque2.GetEnumerator();

            d2.MoveNext();

            foreach (int item in deque)
            {
                Debug.Assert(item.Equals(d2.Current));

                d2.MoveNext();
            }
        }
Exemplo n.º 3
0
        private static void TestClone(Deque deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

            Deque deque2 = (Deque)deque.Clone();

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

            IEnumerator d2 = deque2.GetEnumerator();

            d2.MoveNext();

            foreach (object obj in deque)
            {
                Debug.Assert(obj.Equals(d2.Current));

                d2.MoveNext();
            }
        }
Exemplo n.º 4
0
        private static void TestEnumerator(Deque <int> deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

            IEnumerator <int> e = deque.GetEnumerator();

            try
            {
                int item = e.Current;

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

            try
            {
                foreach (int item in deque)
                {
                    Debug.Assert(e.MoveNext());
                }

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

                int o = e.Current;

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

            try
            {
                e.Reset();

                foreach (int item in deque)
                {
                    Debug.Assert(e.MoveNext());
                }

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

                int 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);
            }
        }