当前位置: 首页>>代码示例>>C#>>正文


C# Deque.Clear方法代码示例

本文整理汇总了C#中Deque.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Deque.Clear方法的具体用法?C# Deque.Clear怎么用?C# Deque.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Deque的用法示例。


在下文中一共展示了Deque.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ClearPUT

        public void ClearPUT([PexAssumeUnderTest]int[] input)
        {
            Deque<int> actual = new Deque<int> (input);
            actual.Clear();

            PexAssert.AreEqual(0, actual.Count);
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:7,代码来源:DequeTest.cs

示例2: ClearTest

        public void ClearTest()
        {
            Deque<int> actual = new Deque<int> { 12, 45, 321 };

            actual.Clear();

            Assert.AreEqual(0, actual.Count);
        }
开发者ID:robertrancz,项目名称:dsa,代码行数:8,代码来源:DequeTest.cs

示例3: TestDeque

        private static void TestDeque(Deque deque)
        {
            deque.Clear();
            System.Diagnostics.Debug.Assert(deque.Count == 0);

            PopulateDequePushFront(deque);
            PopulateDequePushBack(deque);   
            TestPopFront(deque);
            TestPopBack(deque);
            TestContains(deque);
            TestCopyTo(deque);
            TestToArray(deque);
            TestClone(deque);
            TestEnumerator(deque);
        }
开发者ID:natural20s,项目名称:ProjectAccountingSoftware,代码行数:15,代码来源:Tester.cs

示例4: TestDeque

        public static void TestDeque(Deque<int> deque)
        {
            deque.Clear();
            Debug.Assert(deque.Count == 0);

            PopulateDequePushFront(deque);
            PopulateDequePushBack(deque);
            TestPopFront(deque);
            TestPopBack(deque);
            TestContains(deque);
            TestCopyTo(deque);
            TestToArray(deque);
            TestClone(deque);
            TestEnumerator(deque);
        }
开发者ID:blahblahblahblah831,项目名称:brawltools2,代码行数:15,代码来源:GenericTester.cs

示例5: TestPopFront

        private static void TestPopFront(Deque deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

            int j;

            for(int i = 0; i < ElementCount; i++)
            {
                j = (int)deque.PopFront();

                Debug.Assert(j == i);
            }

            Debug.Assert(deque.Count == 0);
        }
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:17,代码来源:Tester.cs

示例6: ClearExample

        public void ClearExample()
        {
            var deque = new Deque<string>();
            deque.EnqueueHead("cat");
            deque.EnqueueHead("dog");
            deque.EnqueueHead("canary");

            // There should be 3 items in the deque.
            Assert.AreEqual(3, deque.Count);

            // Clear the deque
            deque.Clear();

            // The deque should be empty.
            Assert.AreEqual(0, deque.Count);

            // No cat here..
            Assert.IsFalse(deque.Contains("cat"));
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:19,代码来源:DequeExamples.cs

示例7: PopulateDequePushFront

        private static void PopulateDequePushFront(Deque deque)
        {
            deque.Clear();

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

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

            int j = ElementCount - 1;

            foreach(int i in deque)
            {
                System.Diagnostics.Debug.Assert(i == j);
                j--;
            }
        }
开发者ID:jordanajlouni,项目名称:ProjectAccountingSoftware,代码行数:19,代码来源:Tester.cs

示例8: PopulateDequePushBack

        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++;
            }
        }
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:19,代码来源:Tester.cs

示例9: TestClone

        private static void TestClone(Deque deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

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

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

            IEnumerator d2 = deque2.GetEnumerator();

            d2.MoveNext();

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

                d2.MoveNext();
            }
        }
开发者ID:jordanajlouni,项目名称:ProjectAccountingSoftware,代码行数:21,代码来源:Tester.cs

示例10: TestClone

        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();
            }
        }
开发者ID:blahblahblahblah831,项目名称:brawltools2,代码行数:21,代码来源:GenericTester.cs

示例11: IsEmptyExample

        public void IsEmptyExample()
        {
            var deque = new Deque<string>();

            // Deque will be empty initially
            Assert.IsTrue(deque.IsEmpty);

            deque.EnqueueHead("cat");

            // Deque will be not be empty when an item is added
            Assert.IsFalse(deque.IsEmpty);

            deque.Clear();

            // Deque will be empty when items are cleared
            Assert.IsTrue(deque.IsEmpty);
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:17,代码来源:DequeExamples.cs

示例12: TestContains

        private static void TestContains(Deque deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

            for(int i = 0; i < deque.Count; i++)
            {
                System.Diagnostics.Debug.Assert(deque.Contains(i));
            }

            System.Diagnostics.Debug.Assert(!deque.Contains(ElementCount));
        }
开发者ID:jordanajlouni,项目名称:ProjectAccountingSoftware,代码行数:13,代码来源:Tester.cs

示例13: TestToArray

        private static void TestToArray(Deque deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

            object[] array = deque.ToArray();
            int i = 0;

            foreach(object obj in deque)
            {
                System.Diagnostics.Debug.Assert(obj.Equals(array[i]));
                i++;
            }
        }
开发者ID:jordanajlouni,项目名称:ProjectAccountingSoftware,代码行数:15,代码来源:Tester.cs

示例14: TestPopBack

        private static void TestPopBack(Deque deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

            int j;

            for(int i = 0; i < ElementCount; i++)
            {
                j = (int)deque.PopBack();

                System.Diagnostics.Debug.Assert(j == ElementCount - 1 - i);
            }

            System.Diagnostics.Debug.Assert(deque.Count == 0);
        }
开发者ID:jordanajlouni,项目名称:ProjectAccountingSoftware,代码行数:17,代码来源:Tester.cs

示例15: TestEnumerator

        private static void TestEnumerator(Deque deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

            IEnumerator e = deque.GetEnumerator();

            try
            {
                //object obj = e.Current;

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

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

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

                //object o = e.Current;

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

            try
            {
                e.Reset();

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

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

                //object o = e.Current;

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

            try
            {
                deque.PushBack(deque.Count);

                e.Reset();

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

            try
            {
                e.MoveNext();

                UnityEngine.Debug.LogError("Exception failed");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:jordanajlouni,项目名称:ProjectAccountingSoftware,代码行数:81,代码来源:Tester.cs


注:本文中的Deque.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。