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


C# RingBuffer.Add方法代码示例

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


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

示例1: AddItemsToBufferOfSetSize_RemovesItemsFirstAddedToBufferToFitInMoreItems

    public void AddItemsToBufferOfSetSize_RemovesItemsFirstAddedToBufferToFitInMoreItems()
    {
      var buffer = new RingBuffer<string>(2);
      buffer.Add("1");
      buffer.Add("2");

      List<string> items = buffer.ToList();
      Assert.AreEqual("1", items[0]);
      Assert.AreEqual("2", items[1]);

      buffer.Add("3");
      items = buffer.ToList();
      Assert.AreEqual("2", items[0]);
      Assert.AreEqual("3", items[1]);

      buffer.Add("4");
      items = buffer.ToList();
      Assert.AreEqual("3", items[0]);
      Assert.AreEqual("4", items[1]);

      buffer.Add("5");
      items = buffer.ToList();
      Assert.AreEqual("4", items[0]);
      Assert.AreEqual("5", items[1]);
    }
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:25,代码来源:RingBufferTests.cs

示例2: IsFullTest_True

 public void IsFullTest_True()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(1);
     rb.Add(2);
     rb.Add(3);
     rb.Add(4);
     Assert.IsTrue(rb.IsFull);
 }
开发者ID:BobPusateri,项目名称:RingBuffer,代码行数:9,代码来源:RingBuffer_Test.cs

示例3: ReadingFromARingBuffer

        public void ReadingFromARingBuffer()
        {
            RingBuffer<int> r = new RingBuffer<int>(3);
            r.Add(1);
            r.Add(2);
            r.Add(3);
            r.Add(4);

            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(4, r[0]);
            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(2, r[1]);
            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(3, r[2]);
        }
开发者ID:xoxota99,项目名称:Myre,代码行数:12,代码来源:RingBufferTest.cs

示例4: ClearTest_notempty

 public void ClearTest_notempty()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(7);
     Assert.IsFalse(rb.IsEmpty);
     rb.Clear();
     Assert.IsTrue(rb.IsEmpty);
 }
开发者ID:BobPusateri,项目名称:RingBuffer,代码行数:8,代码来源:RingBuffer_Test.cs

示例5: PutIncrementsSize

 public void PutIncrementsSize() {
     RingBuffer<int> _buffer = new RingBuffer<int>(iterations);
     for(int i = 0; i < iterations; i++) {
         int _tmp = i;
         _buffer.Add(_tmp);
         Assert.AreEqual(i + 1, _buffer.Size, "Size is not equal to number of elements added.");
     }
 }
开发者ID:Joe821,项目名称:RingBuffer.NET,代码行数:8,代码来源:RingBufferTests.cs

示例6: AddItemsToBufferOfSetSize_IncreasesSizeUntilFull

    public void AddItemsToBufferOfSetSize_IncreasesSizeUntilFull()
    {
      var buffer = new RingBuffer<string>(2);

      Assert.AreEqual(0, buffer.Count);

      buffer.Add("1");

      Assert.AreEqual(1, buffer.Count);

      buffer.Add("2");

      Assert.AreEqual(2, buffer.Count);

      buffer.Add("3");

      Assert.AreEqual(2, buffer.Count);
    }
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:18,代码来源:RingBufferTests.cs

示例7: Sensor

 public Sensor(SensorIdentification config)
 {
     mID = config.Id;
     mMAC = config.Mac;
     mPortName = config.PortName;
     mData = new RingBuffer<SensorDataEntry>(HISTORY_BUFFER_SIZE);
     /** Add an empty entry in case getLastEntry is called before data comes in */
     mData.Add( new SensorDataEntry() );
     mTimeoutWatch = new System.Diagnostics.Stopwatch();
 }
开发者ID:bittwiddler1,项目名称:SENSOR-AWARE-PERSONAL-TRAINER,代码行数:10,代码来源:Sensor.cs

示例8: AddingToARingBufferWorks

 public void AddingToARingBufferWorks()
 {
     RingBuffer<int> r = new RingBuffer<int>(5);
     r.Add(1);
     r.Add(2);
     r.Add(3);
     r.Add(4);
     r.Add(5);
     r.Add(6);
 }
开发者ID:xoxota99,项目名称:Myre,代码行数:10,代码来源:RingBufferTest.cs

示例9: AddValue

        /// <summary>
        /// Registers one tick for the given name.
        /// </summary>
        /// <param name="name">A string identifying the caller.</param>
        /// <param name="value">The new value.</param>
        public void AddValue(string name, int val)
        {
            RingBuffer<int> rb;
            if (fps.ContainsKey(name)) {
                rb = fps[name];
            } else {
                rb = new RingBuffer<int>(FPS_WINDOW);
                // Fill the RingBuffer with sentinel values so we don't have to
                // do extra bookkeeping.
                for (int i = 0; i < FPS_WINDOW; i++) {
                    rb.Add(-1);
                }
                fps.Add(name, rb);
            }

            lock (rb) {
                rb.Add(val);
            }
        }
开发者ID:tstein,项目名称:rope,代码行数:24,代码来源:stats.cs

示例10: populateBuffer

 private void populateBuffer(int elements, RingBuffer<int> buffer) {
     for(int i = 0; i < elements; i++) {
         buffer.Add(i);
     }
 }
开发者ID:Joe821,项目名称:RingBuffer.NET,代码行数:5,代码来源:RingBufferTests.cs

示例11: ContainsReturnsCorrectly

        public void ContainsReturnsCorrectly() {
            RingBuffer<int> _buffer = new RingBuffer<int>(iterations + 2);
            _buffer.Add(knownValue - 1);
            bool _containsKnownValue = _buffer.Contains(knownValue);
            Assert.AreEqual(false, _containsKnownValue);
            populateBuffer(iterations, _buffer);
            _buffer.Add(knownValue);
            _containsKnownValue = _buffer.Contains(knownValue);
            Assert.AreEqual(true, _containsKnownValue);

        }
开发者ID:Joe821,项目名称:RingBuffer.NET,代码行数:11,代码来源:RingBufferTests.cs

示例12: PeekTest_1

 public void PeekTest_1()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(3);
     rb.Add(5);
     int p1 = rb.Peek();
     int d1 = rb.Remove();
     int p2 = rb.Peek();
     int d2 = rb.Remove();
     Assert.AreEqual(3, p1);
     Assert.AreEqual(5, p2);
     Assert.AreEqual(3, d1);
     Assert.AreEqual(5, d2);
 }
开发者ID:BobPusateri,项目名称:RingBuffer,代码行数:14,代码来源:RingBuffer_Test.cs

示例13: IsFullTest_False_2

 public void IsFullTest_False_2()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(4);
     Assert.IsFalse(rb.IsFull);
 }
开发者ID:BobPusateri,项目名称:RingBuffer,代码行数:6,代码来源:RingBuffer_Test.cs

示例14: IsEmptyTest_False

 public void IsEmptyTest_False()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(4);
     Assert.IsFalse(rb.IsEmpty);
 }
开发者ID:BobPusateri,项目名称:RingBuffer,代码行数:6,代码来源:RingBuffer_Test.cs

示例15: QueueTest_3

 public void QueueTest_3()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(2);
     rb.Add(4);
     rb.Add(6);
     rb.Add(8);
     rb.Add(9);
     int d1 = rb.Remove();
     int d2 = rb.Remove();
     int d3 = rb.Remove();
     int d4 = rb.Remove();
     Assert.AreEqual(4, d1);
     Assert.AreEqual(6, d2);
     Assert.AreEqual(8, d3);
     Assert.AreEqual(9, d4);
     Assert.IsTrue(rb.IsEmpty);
 }
开发者ID:BobPusateri,项目名称:RingBuffer,代码行数:18,代码来源:RingBuffer_Test.cs


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