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


C# CircularBuffer.Contains方法代码示例

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


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

示例1: CircularBuffer_Enqueue

        public void CircularBuffer_Enqueue()
        {
            var buffer = new CircularBuffer<string>(10);
            buffer.Enqueue("test");
            buffer.Enqueue("string");

            CollectionAssert.AreEqual(new[] { "test", "string" }, buffer.ToArray());
            Assert.AreEqual(2, buffer.Count);
            Assert.AreEqual(10, buffer.Capacity);
            Assert.AreEqual(0, buffer.Head);
            Assert.AreEqual(2, buffer.Tail);
            Assert.IsTrue(buffer.Contains("string"));
            Assert.IsFalse(buffer.Contains("other string"));
        }
开发者ID:joaope,项目名称:DataStructuresNET,代码行数:14,代码来源:CircularBufferTest.cs

示例2: Remove_ValueType_RemovesItem

            public void Remove_ValueType_RemovesItem()
            {
                var buffer = new CircularBuffer<int>(3);

                buffer.Add(1);
                buffer.Add(2);
                buffer.Add(3);

                buffer.Remove(2);

                Assert.AreEqual(2, buffer.Count);
                Assert.IsTrue(buffer.Contains(1));
                Assert.IsFalse(buffer.Contains(2));
                Assert.IsTrue(buffer.Contains(3));
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:15,代码来源:CircularBufferTests.cs

示例3: CircularBuffer_Dequeue

        public void CircularBuffer_Dequeue()
        {
            int[] data = { 0, 1, 2, 3 };
            var buffer = new CircularBuffer<int>(data.Length);
            buffer.EnqueueRange(data, 0, data.Length);

            buffer.Dequeue();

            Assert.AreEqual(3, buffer.Count);
            Assert.AreEqual(data.Length, buffer.Capacity);
            Assert.AreEqual(1, buffer.Head);
            Assert.AreEqual(0, buffer.Tail);
            Assert.IsTrue(buffer.Contains(1));
            Assert.IsFalse(buffer.Contains(0));
            CollectionAssert.AreEqual(new[] { 1, 2, 3 }, buffer.ToArray());
        }
开发者ID:joaope,项目名称:DataStructuresNET,代码行数:16,代码来源:CircularBufferTest.cs

示例4: Remove_ReferenceType_RemovesItem

            public void Remove_ReferenceType_RemovesItem()
            {
                var buffer = new CircularBuffer<TestRefType>(3);
                var o1 = new TestRefType(Guid.NewGuid());
                var o2 = new TestRefType(Guid.NewGuid());
                var o3 = new TestRefType(Guid.NewGuid());

                buffer.Add(o1);
                buffer.Add(o2);
                buffer.Add(o3);

                buffer.Remove(o2);

                Assert.AreEqual(2, buffer.Count);
                Assert.IsTrue(buffer.Contains(o1));
                Assert.IsFalse(buffer.Contains(o2));
                Assert.IsTrue(buffer.Contains(o3));
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:18,代码来源:CircularBufferTests.cs

示例5: CircularBuffer_EnqueueOverwriteAllowed

        public void CircularBuffer_EnqueueOverwriteAllowed()
        {
            string[] data = { "a", "b", "c", "d" };
            var buffer = new CircularBuffer<string>(data.Length);
            buffer.EnqueueRange(data, 0, data.Length);

            buffer.Enqueue("z");

            CollectionAssert.AreEqual(new[] { "z", "b", "c", "d" }, buffer.ToArray());
            Assert.AreEqual(data.Length, buffer.Count);
            Assert.AreEqual(data.Length, buffer.Capacity);
            Assert.AreEqual(0, buffer.Head);
            Assert.AreEqual(1, buffer.Tail);
            Assert.IsTrue(buffer.Contains("z"));
            Assert.IsFalse(buffer.Contains("a"));
        }
开发者ID:joaope,项目名称:DataStructuresNET,代码行数:16,代码来源:CircularBufferTest.cs

示例6: CircularBuffer_EnqueueAfterTrimExcess

        public void CircularBuffer_EnqueueAfterTrimExcess()
        {
            var buffer = new CircularBuffer<string>(10);
            buffer.EnqueueRange(new[] { "a", "b", "c" }, 0, 3);

            buffer.TrimExcess();
            buffer.Enqueue("z");

            CollectionAssert.AreEqual(new[] { "z", "b", "c" }, buffer.ToArray());
            Assert.AreEqual(3, buffer.Count);
            Assert.AreEqual(3, buffer.Capacity);
            Assert.AreEqual(0, buffer.Head);
            Assert.AreEqual(1, buffer.Tail);
            Assert.IsTrue(buffer.Contains("z"));
            Assert.IsFalse(buffer.Contains("a"));
        }
开发者ID:joaope,项目名称:DataStructuresNET,代码行数:16,代码来源:CircularBufferTest.cs

示例7: ContainsRefType_NullDoesNotExist_ReturnsTrue

            public void ContainsRefType_NullDoesNotExist_ReturnsTrue()
            {
                var buffer = new CircularBuffer<TestRefType>(3);
                var id1 = Guid.NewGuid();
                var id2 = Guid.NewGuid();
                var id3 = Guid.NewGuid();

                buffer.Add(new TestRefType(id1));
                buffer.Add(new TestRefType(id2));
                buffer.Add(new TestRefType(id3));


                Assert.IsFalse(buffer.Contains(null));
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:14,代码来源:CircularBufferTests.cs

示例8: ContainsRefType_ValueExists_ReturnsTrue

            public void ContainsRefType_ValueExists_ReturnsTrue()
            {
                var buffer = new CircularBuffer<TestRefType>(3);
                var id1 = Guid.NewGuid();
                var id2 = Guid.NewGuid();
                var id3 = Guid.NewGuid();
                var id4 = Guid.NewGuid();

                buffer.Add(new TestRefType(id1));
                buffer.Add(new TestRefType(id2));
                buffer.Add(new TestRefType(id3));
                buffer.Add(new TestRefType(id4));


                Assert.IsTrue(buffer.Contains(new TestRefType(id2)));
                Assert.IsTrue(buffer.Contains(new TestRefType(id3)));
                Assert.IsTrue(buffer.Contains(new TestRefType(id4)));
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:18,代码来源:CircularBufferTests.cs

示例9: ContainsRefType_ValueDoesNotExist_ReturnsFalse

            public void ContainsRefType_ValueDoesNotExist_ReturnsFalse()
            {
                var buffer = new CircularBuffer<TestRefType>(3);
                var id1 = Guid.NewGuid();
                var id2 = Guid.NewGuid();
                var id3 = Guid.NewGuid();
                var id4 = Guid.NewGuid();

                buffer.Add(new TestRefType(id1));
                buffer.Add(new TestRefType(id2));
                buffer.Add(new TestRefType(id3));
                buffer.Add(new TestRefType(id4));


                var result = buffer.Contains(new TestRefType(id1));

                Assert.IsFalse(result);
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:18,代码来源:CircularBufferTests.cs

示例10: ContainsDefaultRefType_NotYetFull_ReturnsFalse

            public void ContainsDefaultRefType_NotYetFull_ReturnsFalse()
            {
                var buffer = new CircularBuffer<TestRefType>(3);
                buffer.Add(new TestRefType(Guid.NewGuid()));
                buffer.Add(new TestRefType(Guid.NewGuid()));

                var result = buffer.Contains(default(TestRefType));

                Assert.IsFalse(result);
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:10,代码来源:CircularBufferTests.cs

示例11: ContainsDefaultInt_NotYetFull_ReturnsFalse

            public void ContainsDefaultInt_NotYetFull_ReturnsFalse()
            {
                var buffer = new CircularBuffer<int>(3);
                buffer.Add(1);
                buffer.Add(2);

                var result = buffer.Contains(default(int));

                Assert.IsFalse(result);
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:10,代码来源:CircularBufferTests.cs

示例12: ContainsInt_ValueDoesNotExist_ReturnsFalse

            public void ContainsInt_ValueDoesNotExist_ReturnsFalse()
            {
                var buffer = new CircularBuffer<int>(3);
                buffer.Add(1);
                buffer.Add(2);
                buffer.Add(3);
                buffer.Add(4);
                buffer.Add(5);
                buffer.Add(6);
                buffer.Add(7);
                buffer.Add(8);

                var result = buffer.Contains(3);

                Assert.IsFalse(result);
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:16,代码来源:CircularBufferTests.cs

示例13: ContainsInt_ValueExists_ReturnsTrue

            public void ContainsInt_ValueExists_ReturnsTrue()
            {
                var buffer = new CircularBuffer<int>(3);
                buffer.Add(1);
                buffer.Add(2);
                buffer.Add(3);
                buffer.Add(4);
                buffer.Add(5);
                buffer.Add(6);
                buffer.Add(7);
                buffer.Add(8);

                Assert.IsTrue(buffer.Contains(6));
                Assert.IsTrue(buffer.Contains(7));
                Assert.IsTrue(buffer.Contains(8));
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:16,代码来源:CircularBufferTests.cs


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