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


C# CircularBuffer类代码示例

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


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

示例1: GetValues

 public LinearRegressionInputData GetValues(
     CircularBuffer<MarketDataPair> data,
     int fromIndex)
 {
     List<MarketDataPair> rangeData = data.PeekRange(fromIndex);
     return GetLinearRegressionData(rangeData);
 }
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:7,代码来源:RegressionPolicyDefault.cs

示例2: WidcommBluetoothStream

 public WidcommBluetoothStream(CircularBuffer buffer, CircularBuffer sbuffer, byte[] address, string pin)
     : base(buffer, sbuffer, address, pin)
 {
     wdStack[0] = WidcommAPI.CreateWidcommStack();
        if (wdStack[0] == IntPtr.Zero)
        throw new Exception("Cannot create stack");
 }
开发者ID:katadam,项目名称:wockets,代码行数:7,代码来源:WidcommBluetoothStream.cs

示例3: TestPushPop

        public void TestPushPop()
        {
            CircularBuffer<double> queue = new CircularBuffer<double>(3);

            queue.PushBack(1.0);
            queue.PushBack(2.0);
            queue.PushBack(3.0);

            Assert.That(queue[0], Is.EqualTo(1.0).Within(0.00005));
            Assert.That(queue[1], Is.EqualTo(2.0).Within(0.00005));
            Assert.That(queue[2], Is.EqualTo(3.0).Within(0.00005));

            //The buffer is now full.

            queue.PushBack(4.0);

            Assert.That(queue[0], Is.EqualTo(2.0).Within(0.00005));
            Assert.That(queue[1], Is.EqualTo(3.0).Within(0.00005));
            Assert.That(queue[2], Is.EqualTo(4.0).Within(0.00005));

            queue.PushBack(5.0);

            Assert.That(queue[0], Is.EqualTo(3.0).Within(0.00005));
            Assert.That(queue[1], Is.EqualTo(4.0).Within(0.00005));
            Assert.That(queue[2], Is.EqualTo(5.0).Within(0.00005));

            queue.PopBack();
            Assert.That(queue[0], Is.EqualTo(3.0).Within(0.00005));
            Assert.That(queue[1], Is.EqualTo(4.0).Within(0.00005));

            queue.PopFront();

            Assert.That(queue[0], Is.EqualTo(4.0).Within(0.00005));

        }
开发者ID:chopshop-166,项目名称:WPILib,代码行数:35,代码来源:TestCircularBuffer.cs

示例4: OverflowException

        public void OverflowException()
        {
            var buffer = new CircularBuffer<int>(4);

            for (int i = 0; i < 32; i++)
                buffer.Put(i);
        }
开发者ID:pjc0247,项目名称:Merona.cs,代码行数:7,代码来源:CircularBuffer.cs

示例5: Get

        public QueueClient Get(Address address)
        {
            var key = address.ToString();
            var buffer = queueClients.GetOrAdd(key, s =>
            {
                var b = new CircularBuffer<QueueClientEntry>(numberOfQueueClientsPerAddress);
                for (var i = 0; i < numberOfQueueClientsPerAddress; i++)
                {
                    var factory = messagingFactories.Get(address);
                    b.Put(new QueueClientEntry
                    {
                        Client = queueClientCreator.Create(address.Queue, factory)
                    });
                }
                return b;
            });

            var entry = buffer.Get();

            if (entry.Client.IsClosed)
            {
                lock (entry.mutex)
                {
                    if (entry.Client.IsClosed)
                    {
                        var factory = messagingFactories.Get(address);
                        entry.Client = queueClientCreator.Create(address.Queue, factory);
                    }
                }
            }

            return entry.Client;

        }
开发者ID:danielmarbach,项目名称:NServiceBus.AzureServiceBus,代码行数:34,代码来源:ManageQueueClientsLifeCycle.cs

示例6: CircularBufferExt_DecoderConvert1_BoundariesFlush

        public void CircularBufferExt_DecoderConvert1_BoundariesFlush()
        {
            Encoding enc = Encoding.GetEncoding("UTF-8");
            Decoder d = enc.GetDecoder();

            byte[] m = new byte[] {
                0xAC, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
                0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E,
                0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
                0x57, 0x58, 0x59, 0x5A, 0xE2, 0x82
            };
            char[] c = new char[28];
            CircularBuffer<byte> cb = new CircularBuffer<byte>(m, 16, m.Length);

            int bu;
            int cu;
            bool complete;

            // Based on the test "Decoder_Boundaries2"
            d.Convert(cb, c, 0, c.Length, true, out bu, out cu, out complete);
            Assert.IsTrue(complete);
            Assert.AreEqual(m.Length, bu);
            Assert.AreEqual(0, cb.Length);
            Assert.AreEqual(c.Length, cu);
            Assert.AreEqual("OPQRSTUVWXYZ€@ABCDEFGHIJKLMN", new string(c));
        }
开发者ID:DHMechatronicAG,项目名称:SerialPortStream,代码行数:26,代码来源:CircularBufferTest.cs

示例7: Awake

 protected virtual void Awake()
 {
     _activeTrail = new CircularBuffer<PCTrailPoint>(MaxNumberOfPoints);
     _fadingTrails = new List<CircularBuffer<PCTrailPoint>>();
     _t = transform;
     _emit = Emit;
 }
开发者ID:oathx,项目名称:Six,代码行数:7,代码来源:TrailRenderer_Base.cs

示例8: LevelReset

	public void LevelReset(float liveCount){
		timeOfDeath = float.PositiveInfinity;
		playerEvents = new CircularBuffer<PlayerEvent>(2);
		roundScore = 0f;
		lived = false;
		lives = liveCount;
	}
开发者ID:RobbSteel,项目名称:Lords-of-Distortion,代码行数:7,代码来源:PlayerStats.cs

示例9: Recycle

 internal void Recycle(CircularBuffer<byte[]> buffer)
 {
     if (buffer != null)
     {
         while (buffer.Count != 0) Recycle(buffer.Pop());
     }
 }
开发者ID:ReinhardHsu,项目名称:NetGain,代码行数:7,代码来源:NetContext.cs

示例10: init

    // Use this for initialization
    void init()
    {
        //Loop through the object prefabs and make a new list for each one.
        //We do this because the pool can only support prefabs set to it in the editor,
        //so we can assume the lists of pooled objects are in the same order as object prefabs in the array
        _objects = new CircularBuffer<GameObject>[_prefabs.Length];

        int i = 0;
        foreach ( GameObject objectPrefab in _prefabs )
        {
            _objects[i] = new CircularBuffer<GameObject>(_bufferAmount[i]);

            for ( int n=0; n<_bufferAmount[i]; n++)
            {

                GameObject obj = Instantiate(objectPrefab) as GameObject;
                obj.name = objectPrefab.name;

                obj.SetActiveRecursively(false);
                obj.transform.parent = transform;
                _objects[i].Add(obj);
            }
            i++;
        }
    }
开发者ID:silantzis,项目名称:blockotron,代码行数:26,代码来源:CircularObjectPool.cs

示例11: LinearDigitalFilter

 /// <summary>
 /// Creates a linear FIR or IIR filter.
 /// </summary>
 /// <param name="source">The <see cref="IPIDSource"/> object that is used to get values.</param>
 /// <param name="ffGains">The "feed forward" or FIR gains.</param>
 /// <param name="fbGains">The "feed back" or IIR gains.</param>
 public LinearDigitalFilter(IPIDSource source, double[] ffGains, double[] fbGains) : base(source)
 {
     m_inputs = new CircularBuffer<double>(ffGains.Length);
     m_outputs = new CircularBuffer<double>(fbGains.Length);
     m_inputGains = ffGains;
     m_outputGains = fbGains;
 }
开发者ID:chopshop-166,项目名称:WPILib,代码行数:13,代码来源:LinearDigitalFilter.cs

示例12: Get

        public MessagingFactory Get(Address address)
        {
            var key = address.ToString();
            var buffer = MessagingFactories.GetOrAdd(key, s => {
                var b = new CircularBuffer<FactoryEntry>(numberOfFactoriesPerAddress);
                for(var i = 0; i < numberOfFactoriesPerAddress; i++) 
                    b.Put(new FactoryEntry { Factory = createMessagingFactories.Create(address) });
                return b;
            });

            var entry = buffer.Get();

            if (entry.Factory.IsClosed)
            {
                lock (entry.mutex)
                {
                    if (entry.Factory.IsClosed)
                    {
                        entry.Factory = createMessagingFactories.Create(address);
                    }
                }
            }

            return entry.Factory;

        }
开发者ID:danielmarbach,项目名称:NServiceBus.AzureServiceBus,代码行数:26,代码来源:ManageMessagingFactoriesLifeCycle.cs

示例13: Clone

	public object Clone()
	{
		CircularBuffer cb = new CircularBuffer(this.Count);
		cb.buf = (double[])this.buf.Clone();
		cb.top = this.top;
		return cb;
	}
开发者ID:ufcpp,项目名称:UfcppSample,代码行数:7,代码来源:CircularBuffer2.cs

示例14: IirFilter

	/// <summary>
	/// 係数を配列で指定して初期化
	/// </summary>
	/// <param name="a">分母係数を格納した配列</param>
	/// <param name="b">分子係数を格納した配列</param>
	/// <param name="c">ゲイン</param>
	public IirFilter(double[] a, double[] b, double c)
	{
		this.a = a;
		this.b = b;
		this.c = c;
		this.buf = new CircularBuffer(a.Length);
	}
开发者ID:ufcpp,项目名称:UfcppSample,代码行数:13,代码来源:IirFilter.cs

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


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