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


C# CircularBuffer.RemoveFromHead方法代码示例

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


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

示例1: IsEmpty

        public void IsEmpty()
        {
            var rnd = new Random();
            var buffer = new CircularBuffer<int>(1);

            Assert.IsTrue(buffer.IsEmpty, "Step 1");
            buffer.AddToHead(rnd.Next());
            Assert.IsFalse(buffer.IsEmpty, "Step 2");
            buffer.AddToHead(rnd.Next());
            Assert.IsFalse(buffer.IsEmpty, "Step 3");
            buffer.RemoveFromHead();
            Assert.IsTrue(buffer.IsEmpty, "Step 4");
        }
开发者ID:vpfau,项目名称:Algorithms,代码行数:13,代码来源:CircularBufferTesting.cs

示例2: LengthTest

        public void LengthTest()
        {
            var rnd = new Random();
            var buffer = new CircularBuffer<int>(1);

            Assert.That(buffer.Length, Is.EqualTo(0), "0. Expected 0 length");
            buffer.AddToHead(rnd.Next());
            Assert.That(buffer.Length, Is.EqualTo(1), "1. Expected 1 length");
            buffer.AddToHead(rnd.Next());
            Assert.That(buffer.Length, Is.EqualTo(1), "2. Expected 1 length");
            buffer.RemoveFromHead();
            Assert.That(buffer.Length, Is.EqualTo(0), "3. Expected 0 length");
        }
开发者ID:vpfau,项目名称:Algorithms,代码行数:13,代码来源:CircularBufferTesting.cs

示例3: SingleElementBuffer

        public void SingleElementBuffer()
        {
            var rnd = new Random();
            var buffer = new CircularBuffer<int>(1);

            int value1 = rnd.Next();
            buffer.AddToHead(value1);

            Assert.That(buffer.Head, Is.EqualTo(buffer.Tail), "1. Single element buffer expect Tail equal Head");
            Assert.That(buffer.Head, Is.EqualTo(value1), "1. Head shoud be equal the last added value");

            value1 = rnd.Next();
            buffer.AddToHead(value1);

            Assert.That(buffer.Head, Is.EqualTo(buffer.Tail), "2. Single element buffer expect Tail equal Head");
            Assert.That(buffer.Head, Is.EqualTo(value1), "2. Head shoud be equal the last added value");
            Assert.That(buffer.RemoveFromHead(), Is.EqualTo(value1), "2. Remove from head should return the last added value");
        }
开发者ID:vpfau,项目名称:Algorithms,代码行数:18,代码来源:CircularBufferTesting.cs

示例4: RemoveFromHeadTest

        public void RemoveFromHeadTest()
        {
            var rnd = new Random();
            var buffer = new CircularBuffer<int>(2);

            var head = rnd.Next();
            var tail = rnd.Next();

            buffer.AddToHead(head);
            buffer.AddToTail(tail);

            Assert.That(buffer.Head, Is.EqualTo(head), "Invalid head value");
            Assert.That(buffer.Tail, Is.EqualTo(tail), "Invalid tail value");
            Assert.That(buffer.Length, Is.EqualTo(2), "Invalid Length value");

            Assert.That(buffer.RemoveFromHead(), Is.EqualTo(head), "Step 1");
            Assert.That(buffer.RemoveFromHead(), Is.EqualTo(tail), "Step 2");
            Assert.That(buffer.IsEmpty, Is.True, "Buffer should be empty");
            Assert.Throws(typeof(InvalidOperationException), () => buffer.RemoveFromHead());
        }
开发者ID:vpfau,项目名称:Algorithms,代码行数:20,代码来源:CircularBufferTesting.cs


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