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


C# CircularBuffer.Add方法代码示例

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


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

示例1: CreateTrail

 public void CreateTrail(Vector3 from, Vector3 to, float distanceBetweenPoints)
 {
     float num = Vector3.Distance(from, to);
     Vector3 normalized = (to - from).normalized;
     float num2 = 0f;
     CircularBuffer<PCTrailPoint> circularBuffer = new CircularBuffer<PCTrailPoint>(this.GetMaxNumberOfPoints());
     int num3 = 0;
     while (num2 < num)
     {
         PCTrailPoint pCTrailPoint = new PCTrailPoint();
         pCTrailPoint.PointNumber = num3;
         pCTrailPoint.Position = from + normalized * num2;
         circularBuffer.Add(pCTrailPoint);
         this.InitialiseNewPoint(pCTrailPoint);
         num3++;
         if (distanceBetweenPoints <= 0f)
         {
             break;
         }
         num2 += distanceBetweenPoints;
     }
     PCTrailPoint pCTrailPoint2 = new PCTrailPoint();
     pCTrailPoint2.PointNumber = num3;
     pCTrailPoint2.Position = to;
     circularBuffer.Add(pCTrailPoint2);
     this.InitialiseNewPoint(pCTrailPoint2);
     PCTrail pCTrail = new PCTrail(this.GetMaxNumberOfPoints());
     pCTrail.Points = circularBuffer;
     this._fadingTrails.Add(pCTrail);
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:30,代码来源:TrailRenderer_Base.cs

示例2: ShouldSaveWithoutOverflow

		public void ShouldSaveWithoutOverflow()
		{
			var buffer = new CircularBuffer<int>(5);
			buffer.Add(1);
			buffer.Add(2);
			buffer.Add(3);
			CollectionAssert.AreEqual(new [] { 1, 2, 3 }, buffer);
		}
开发者ID:rte-se,项目名称:emul8,代码行数:8,代码来源:ClampingBufferTests.cs

示例3: YieldSign

	/*
	 * coroutine
	IEnumerator YieldSign() {
		print ("spawn yield symbol");
		yield return new WaitForSeconds(2);
		PowerSpawn();
	}

	void  PowerSpawn(){
		print ("spawn power");
	}

	void Start() {
		StartCoroutine(YieldSign());
		print ("disable button");
	}
*/

	void Start(){
		CircularBuffer<int> buffer = new CircularBuffer<int>(2);
		buffer.Add(1);
		buffer.Add(2);
		buffer.Add(3);
		foreach(int i in buffer.Reverse<int>()){
			print (i);
		}
	}
开发者ID:RobbSteel,项目名称:Lords-of-Distortion,代码行数:27,代码来源:Test.cs

示例4: Add_MoreThanCapacity_ProperlyCircles

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

                Assert.AreEqual(2, buffer.Skip(0).First());
                Assert.AreEqual(3, buffer.Skip(1).First());
                Assert.AreEqual(4, buffer.Skip(2).First());
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:12,代码来源:CircularBufferTests.cs

示例5: Remove_RemoveSecondItemAndAddTwoItems_OrderIsRight

        public void Remove_RemoveSecondItemAndAddTwoItems_OrderIsRight()
        {
            //Create a circular buffer where the first item is overridden
            var target = new CircularBuffer<int>(3) { 1, 2, 3, 4 };

            target.Remove(2);

            target.Add(5);
            target.Add(6);

            var expected = new List<int> { 6, 3, 5 };

            Assert.IsTrue(target.SequenceEqual(expected));
            Assert.IsTrue(target.Capacity == 3);
        }
开发者ID:mdabbagh88,项目名称:Rareform,代码行数:15,代码来源:CircularBufferTest.cs

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

示例7: TestRollover

        public void TestRollover()
        {
            int bufferSize = 3;
            CircularBuffer<int> circularBuffer = new CircularBuffer<int>(bufferSize);

            for (int i = 0; i < 3; i++)
            {
                circularBuffer.Add(i);
                VerifyContent(circularBuffer, 0, i);
            }

            for (int i = 3; i < 8; i++)
            {
                circularBuffer.Add(i);
                VerifyContent(circularBuffer, i - bufferSize + 1, i);
            }
        }
开发者ID:James-Lockwood,项目名称:lightstone4net,代码行数:17,代码来源:CircularBufferTests.cs

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

示例9: ShouldSaveWithOverflow

		public void ShouldSaveWithOverflow()
		{
			var buffer = new CircularBuffer<int>(4);
			for(var i = 0; i < 6; i++)
			{
				buffer.Add(i);
			}
			Assert.AreEqual(buffer, new [] { 3, 4, 5 });
		}
开发者ID:rte-se,项目名称:emul8,代码行数:9,代码来源:ClampingBufferTests.cs

示例10: TestAccessByIndex

        public void TestAccessByIndex()
        {
            int bufferSize = 3;
            CircularBuffer<int> circularBuffer = new CircularBuffer<int>(bufferSize);

            for (int i = 0; i < 3; i++)
            {
                circularBuffer.Add(i);
            }
            // not rolled over yet
            Assert.AreEqual(1, circularBuffer[1]);

            for (int i = 3; i < 8; i++)
            {
                circularBuffer.Add(i);
            }
            // rolled over
            Assert.AreEqual(6, circularBuffer[1]);
        }
开发者ID:James-Lockwood,项目名称:lightstone4net,代码行数:19,代码来源:CircularBufferTests.cs

示例11: ShouldSaveWithOverflowArray

		public void ShouldSaveWithOverflowArray()
		{
			var buffer = new CircularBuffer<int>(4);
			for(var i = 0; i < 6; i++)
			{
				buffer.Add(i);
			}
			var result = new [] { 3, 4, 5 };
			var copy = new int[3];
			buffer.CopyTo(copy, 0);
			Assert.AreEqual(result, copy);
		}
开发者ID:rte-se,项目名称:emul8,代码行数:12,代码来源:ClampingBufferTests.cs

示例12: ShouldSaveWithoutOverflowArray

		public void ShouldSaveWithoutOverflowArray()
		{
			var buffer = new CircularBuffer<int>(5);
			var array = new [] { 1, 2, 3, -1, 0 };
			for(var i = 0; i < 3; i++)
			{
				buffer.Add(array[i]);
			}
			var copy = new int[5];
			copy[3] = -1;
			buffer.CopyTo(copy, 0);
			CollectionAssert.AreEqual(array, copy);
		}
开发者ID:rte-se,项目名称:emul8,代码行数:13,代码来源:ClampingBufferTests.cs

示例13: Add_HugeNumber_WorksCorrectly

            [Ignore] // This test runs for ages, only run if needed
            public void Add_HugeNumber_WorksCorrectly()
            {
                var buffer = new CircularBuffer<long>(100000);
                var random = new Random();

                long lastValue = 0;

                for (long i = 0; i < int.MaxValue + 1000L; i++)
                {
                    lastValue++;
                    buffer.Add(lastValue);
                }

                long testValue = lastValue - buffer.Count + 1;
                foreach (var item in buffer)
                {
                    Assert.AreEqual(testValue, item);
                    testValue++;
                }
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:21,代码来源:CircularBufferTests.cs

示例14: Enumerate_Reset_ProperlyResets

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

                var en = buffer.GetEnumerator();
                en.MoveNext();
                Assert.AreEqual(1, en.Current);
                en.MoveNext();
                Assert.AreEqual(2, en.Current);
                en.Reset();
                en.MoveNext();
                Assert.AreEqual(1, en.Current);
                en.MoveNext();
                Assert.AreEqual(2, en.Current);
            }
开发者ID:EliSchleifer,项目名称:mstum.utils,代码行数:18,代码来源:CircularBufferTests.cs

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


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