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


C# CircularBuffer.EnqueueRange方法代码示例

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


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

示例1: CircularBuffer_CopyTo

        public void CircularBuffer_CopyTo()
        {
            var data = new[] { 12, 4, 9, 43, 0 };
            var buffer = new CircularBuffer<int>(10);
            buffer.EnqueueRange(data, 0, data.Length);

            var dataCopy = new int[5];
            buffer.CopyTo(dataCopy, 0, 5);

            CollectionAssert.AreEqual(new[] { 12, 4, 9, 43, 0 }, dataCopy);
        }
开发者ID:joaope,项目名称:DataStructuresNET,代码行数:11,代码来源:CircularBufferTest.cs

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

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

示例5: CircularBuffer_IndexerGet

        public void CircularBuffer_IndexerGet()
        {
            var buffer = new CircularBuffer<int>(10);
            buffer.EnqueueRange(
                new[] { 12, 4, 9, 43, 0 },
                0, 5);

            Assert.AreEqual(12, buffer[0]);
            Assert.AreEqual(0, buffer[4]);

            buffer.TrimExcess();
            buffer.EnqueueRange(new[] { 99, 100 }, 0, 2);

            Assert.AreEqual(99, buffer[0]);
            Assert.AreEqual(9, buffer[2]);
        }
开发者ID:joaope,项目名称:DataStructuresNET,代码行数:16,代码来源:CircularBufferTest.cs

示例6: CircularBuffer_EnqueueOverwriteNotAllowed

 public void CircularBuffer_EnqueueOverwriteNotAllowed()
 {
     int[] data = { 1, 2, 3, 4, 5 };
     var buffer = new CircularBuffer<int>(data.Length, false);
     buffer.EnqueueRange(data, 0, data.Length);
     buffer.Enqueue(10);
 }
开发者ID:joaope,项目名称:DataStructuresNET,代码行数:7,代码来源:CircularBufferTest.cs


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