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


C# Deque.Contains方法代码示例

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


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

示例1: Simple

        public void Simple()
        {
            var test = new Deque<int>();
            Assert.IsFalse(test.Contains(5));

            test.EnqueueHead(5);
            test.EnqueueHead(6);

            Assert.IsTrue(test.Contains(5));
            Assert.IsTrue(test.Contains(6));
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:11,代码来源:Contains.cs

示例2: ContainsPUT

        public void ContainsPUT([PexAssumeUnderTest]IList<int> values, int val)
        {
            PexAssume.IsTrue(values.Contains(val));
            Deque<int> actual = new Deque<int> (values);

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

示例3: 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

示例4: Main

        internal static void Main()
        {
            Deque<string> deque = new Deque<string>();
            string peterName = "Peter";
            deque.PushFirst(peterName);
            deque.PushLast("Last element");
            deque.PushFirst("Before Peter");
            deque.PushLast("After last element");

            //This will return 4
            Console.WriteLine("Number of elements: {0}", deque.Count);

            //This will return true, because "Peter" is in the deque
            Console.WriteLine("If deque contains: {0}, -> {1}", peterName, deque.Contains(peterName));

            //This will return first element without removing it.
            Console.WriteLine(deque.PeekFirst());

            //This will return last element and remove it.
            Console.WriteLine(deque.PopLast());
        }
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:21,代码来源:strings+deque.cs

示例5: ContainsExample

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

            // deque does contain cat, dog and canary
            Assert.IsTrue(deque.Contains("cat"));
            Assert.IsTrue(deque.Contains("dog"));
            Assert.IsTrue(deque.Contains("canary"));
            // but not frog
            Assert.IsFalse(deque.Contains("frog"));
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:14,代码来源:DequeExamples.cs

示例6: 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

示例7: TestContains

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

            PopulateDequePushBack(deque);

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

            Debug.Assert(!deque.Contains(ElementCount));
        }
开发者ID:blahblahblahblah831,项目名称:brawltools2,代码行数:13,代码来源:GenericTester.cs

示例8: ContainsTest

        public void ContainsTest()
        {
            Deque<int> actual = new Deque<int> { 12, 4325, 89 };

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

示例9: TestAdd

        public void TestAdd()
        {
            Deque<int> deque = new Deque<int>();

            Assert.IsTrue(deque.IsEmpty);

            int item = 1;

            Assert.IsFalse(deque.Contains(item));
            deque.Add(item);

            int actualBack;
            actualBack = deque[0];

            Assert.IsTrue(deque.Contains(item));
            Assert.AreEqual(item, actualBack);

            int itemNewBack = 2;
            Assert.IsFalse(deque.Contains(itemNewBack));
            deque.AddBack(itemNewBack);

            Assert.IsTrue(deque.Contains(itemNewBack));
            actualBack = deque[1];
            Assert.AreEqual(itemNewBack, actualBack);

            actualBack = deque.RemoveBack();
            Assert.AreEqual(itemNewBack, actualBack);

            int itemNewFront = -1;
            Assert.IsFalse(deque.Contains(itemNewFront));
            deque.AddFront(itemNewFront);

            int actualFront;
            Assert.IsTrue(deque.Contains(itemNewFront));

            actualFront = deque[0];
            Assert.AreEqual(itemNewFront, actualFront);

            actualFront = deque.RemoveFront();
            Assert.AreEqual(itemNewFront, actualFront);

            int[] itemRange = new[] { 3, 4, 5, 6 };
            int offset = deque.Count;
            deque.AddRange(itemRange);

            foreach (var itm in itemRange)
            {
                Assert.AreEqual(itm, deque[offset]);
                offset++;
            }

            int[] itemBackRange = new[] { 7, 8, 9, 10 };
            offset = deque.Count;
            deque.AddBackRange(itemBackRange);
            foreach (var itm in itemBackRange)
            {
                Assert.AreEqual(itm, deque[offset]);
                offset++;
            }

            int[] itemFrontRange = new[] { 3, 4, 5, 6 };
            deque.AddFrontRange(itemFrontRange);

            for (int i = 0; i < itemFrontRange.Length; i++)
            {
                var itm = itemFrontRange[i];
                Assert.AreEqual(itm, deque[i]);
            }
        }
开发者ID:telefunkenvf14,项目名称:Deque,代码行数:69,代码来源:DequeTests.cs

示例10: TestRemove

        public void TestRemove()
        {
            int[] items = new[] { 0, 1, 2, 3 };
            Deque<int> deque = new Deque<int>(items);

            Assert.IsTrue(deque.Contains(0));
            Assert.IsTrue(deque.Remove(0));
            Assert.IsFalse(deque.Contains(0));
            Assert.AreEqual(1, deque.RemoveFront());
            Assert.AreEqual(3, deque.RemoveBack());

            deque.Clear();
            deque.AddRange(items);
            Assert.IsTrue(deque.Contains(2));
            deque.RemoveAt(2);
            Assert.IsFalse(deque.Contains(2));

            deque.Clear();
            deque.AddRange(items);

            foreach (var item in items)
            {
                Assert.IsTrue(deque.Contains(item));
            }

            deque.RemoveRange(1, 2);

            Assert.IsTrue(deque.Contains(0));
            Assert.IsFalse(deque.Contains(1));
            Assert.IsFalse(deque.Contains(2));
            Assert.IsTrue(deque.Contains(3));
        }
开发者ID:telefunkenvf14,项目名称:Deque,代码行数:32,代码来源:DequeTests.cs

示例11: TestConstructor

        public void TestConstructor()
        {
            Deque<int> deque;

            deque = new Deque<int>();
            Assert.AreEqual(16, deque.Capacity);

            deque = new Deque<int>(8);
            Assert.AreEqual(8, deque.Capacity);

            int[] arr = new [] {0,1,2,3,4,5,6,7};
            deque = new Deque<int>(arr);
            Assert.AreEqual(arr.Length, deque.Capacity);
            foreach (int item in arr)
            {
                Assert.IsTrue(deque.Contains(item));
            }
        }
开发者ID:telefunkenvf14,项目名称:Deque,代码行数:18,代码来源:DequeTests.cs


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