Пример #1
0
 void Start()
 {
     for (int i = 0; i < 300; i++)
     {
         m_Data.Add(10);
     }
 }
Пример #2
0
        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]);
        }
    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]);
    }
Пример #4
0
        public void RandomTest()
        {
            var TestObject = new RingBuffer <int>(10);
            var Rand       = new System.Random();
            var Value      = 0;

            for (var x = 0; x < 10; ++x)
            {
                Value = Rand.Next();
                TestObject.Add(Value);
                Assert.Single(TestObject);
                Assert.Equal(Value, TestObject.Remove());
            }
            Assert.Empty(TestObject);
            var Values = new System.Collections.Generic.List <int>();

            for (var x = 0; x < 10; ++x)
            {
                Values.Add(Rand.Next());
            }
            TestObject.Add(Values);
            Assert.Equal(Values.ToArray(), TestObject.ToArray());

            for (var x = 0; x < 10; ++x)
            {
                Assert.Throws <InvalidOperationException>(() => TestObject.Add(Rand.Next()));
                Assert.Equal(10, TestObject.Count);
            }
        }
Пример #5
0
        public virtual void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (_enableGizmos)
            {
                drawer.PushMatrix();
                drawer.matrix = this.transform.localToWorldMatrix;

                drawer.color = Color.green;
                if (isActivated)
                {
                    drawer.color = Color.white;
                }
                drawer.DrawWireCube(GetActivationVolumeBoxOffset(), GetActivationVolumeBoxBounds());

                if (_gizmoColors == null)
                {
                    _gizmoColors = new RingBuffer <Color>(4);
                    _gizmoColors.Add(Color.red);
                    _gizmoColors.Add(Color.yellow);
                    _gizmoColors.Add(Color.green);
                    _gizmoColors.Add(Color.blue);
                }
                for (int i = 0; i < _layers.Length; i++)
                {
                    drawer.color = _gizmoColors.Get(i);
                    drawer.DrawWireCube(Vector3.up * _layers[i].height, new Vector3(_xWidth - 0.2F, 0.01F, _zWidth - 0.2F));
                    drawer.DrawWireCube(Vector3.up * _layers[i].height, new Vector3(_xWidth - 0.4F, 0.01F, _zWidth - 0.4F));
                    drawer.DrawWireCube(Vector3.up * _layers[i].height, new Vector3(_xWidth - 0.6F, 0.01F, _zWidth - 0.6F));
                }

                drawer.PopMatrix();
            }
        }
Пример #6
0
 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);
 }
Пример #7
0
        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]);
        }
Пример #8
0
        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);
        }
Пример #9
0
        public void JaggedAddTest()
        {
            var   dataCount = 8;
            var   dataSize  = 1;
            int   outDataSize;
            ulong outTimestamp;


            var data = new byte[dataSize];

            try
            {
                var buffer = new RingBuffer(dataCount, dataSize);

                for (var i = 1; i < 40; i++)
                {
                    data[0] = (byte)i;
                    buffer.Add(ref data);
                    buffer.Add(ref data);
                    buffer.Add(ref data);
                    buffer.Add(ref data);
                    buffer.Remove(ref data, out outDataSize, out outTimestamp);
                    if (data[0] != i)
                    {
                        Assert.Fail("Returned value does not match expected value");
                    }
                    buffer.Remove(ref data, out outDataSize, out outTimestamp);
                    if (data[0] != i)
                    {
                        Assert.Fail("Returned value does not match expected value");
                    }
                    buffer.Remove(ref data, out outDataSize, out outTimestamp);
                    if (data[0] != i)
                    {
                        Assert.Fail("Returned value does not match expected value");
                    }
                    buffer.Remove(ref data, out outDataSize, out outTimestamp);
                    if (data[0] != i)
                    {
                        Assert.Fail("Returned value does not match expected value");
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail($"Exception in {nameof(JaggedAddTest)}: {ex.Message}");
            }
        }
Пример #10
0
        private static void ReceivingNetworkWorkerThread(UdpClient client, IPEndPoint localEp)
        {
            while (!_pendingExit)
            {
                var data = client.Receive(ref localEp);
                if (data == null)
                {
                    continue;
                }

                if (!_packetsStarted)
                {
                    PrintToConsole("Started receiving multicast packets...");
                    _packetsStarted = true;
                }
                try
                {
                    _ringBuffer.Add(ref data);
                }
                catch (Exception ex)
                {
                    PrintToConsole($@"Unhandled exception within network receiver: {ex.Message}");
                    return;
                }
            }
        }
Пример #11
0
        public void AddColumn(double[] newColumn)
        {
            // Add new column to image
            double[] column = image.Count < image.Length ? new double[height] : image[0];
            image.Add(column);

            // Set values of new column
            Array.Copy(newColumn, column, column.Length);

            // Add new column to integral image
            integralImage.Add(integralImage.Count < integralImage.Length ? new double[height] : integralImage[0]);

            // Calculate integral image
            var col  = image[0];
            var icol = integralImage[0];

            icol[0] = col[0];                     // set (0, 0)
            for (int y = 1; y < height; y++)      // iterate (0, 1...h)
            {
                icol[y] = col[y] + icol[y - 1];   // set (0, y)
            }
            for (int x = 1; x < image.Count; x++) // iterate (1...w, y)
            {
                col = image[x];
                var prevIcol = icol;
                icol    = integralImage[x];
                icol[0] = col[0] + prevIcol[0];                                     // set (x, 0)
                for (int y = 1; y < height; y++)                                    // iterate (x, 1...h)
                {
                    icol[y] = col[y] + prevIcol[y] - prevIcol[y - 1] + icol[y - 1]; // set (x, y)
                }
            }
        }
Пример #12
0
 public void WriteLine(string message)
 {
     lock (bufferLock)
     {
         ringBuffer.Add(message);
     }
 }
Пример #13
0
    void DetectJump(float value)
    {
        buffer.Add(value);

        // calculate fft
        PrepareBuffer();
        FFT.CalculateFFT(fftBuffer, false);

        // check frequency band
        var amp = (float)fftBuffer[frequencyBand].magnitude * 2;

        // show debug info
        var scoreText = (GameObject.Find("DebugText").GetComponent("GUIText") as GUIText);

        scoreText.text = "Input: " + input.Value + "\nFFT: " + amp + "\nMax: " + maxAmp;

        if (maxAmp < amp)
        {
            maxAmp = amp;
        }

        if (c == 100)
        {
            c      = 0;
            maxAmp = 0;
        }

        // jump
        if (amp >= threshold)
        {
            jump.Jump();
        }

        c++;
    }
Пример #14
0
    public static void FilterInput(List <InputResponse> responses)
    {
        bool called;

        while (eventBuffer.Count > 0)
        {
            InputEvent e = eventBuffer.PopFront();
            called = false;
            for (int i = 0; i < responses.Count; i++)
            {
                if (e.type == responses[i].inputEvent.type)
                {
                    responses[i].action(); called = true;
                }
            }
            if (!called)
            {
                buff.Add(e);
            }
        }

        while (buff.Count > 0)
        {
            InputEvent e = buff.PopFront(); eventBuffer.Add(e);
        }
    }
Пример #15
0
        private void AddControlPoint(Vector3 pos)
        {
            for (int i = 0; i < pointsInMiddle; i++)
            {
                AddPoint(new TrailPoint(), pos);
            }
            AddPoint(new TrailPoint(), pos);
            AdditionalPoint ap = new AdditionalPoint {
                position = pos
            };

            switch (parameter.orientationType)
            {
            case TrailOrientation.World:
                ap.forward = parameter.forwardOverride;
                break;

            case TrailOrientation.Local:
                ap.forward = m_transform.forward;
                break;

            case TrailOrientation.LookAt:
                ap.forward = (parameter.lookAt.position - m_transform.position).normalized;
                break;

            default:
                break;
            }

            controlPoints.Add(ap);
        }
        public void Receive(Pose data)
        {
            if (buffer.Capacity == 0)
            {
                OnSend(data);
            }

            bool bufferWasNotFull = false;

            if (!buffer.IsFull)
            {
                bufferWasNotFull = true;
            }

            buffer.Add(data);

            if (buffer.IsFull)
            {
                if (bufferWasNotFull)
                {
                    for (int i = 1; i < buffer.Count; i += 2)
                    {
                        OnSend(getAverage(0, i));
                    }
                }

                OnSend(getAverage(0, buffer.Count));
            }
        }
Пример #17
0
        public bool ReadAvailable(RingBuffer <TValue> buffer)
        {
            var index = _indexControlledByClient.Read();

            if (index < 0)
            {
                // we don't own a buffer, so we can end our request to release one
                _clientReleasesBuffer.SynchronousWrite(false);
                // we need to request a buffer
                _clientRequestsBuffer.SynchronousWrite(true);

                // we didn't read anything
                return(false);
            }
            else
            {
                // our buffer request has been granted, so we can end the request
                _clientRequestsBuffer.SynchronousWrite(false);
                var values = _bufferVariables[index].Read();
                // we are finished reading our buffer, so we can release it
                _clientReleasesBuffer.SynchronousWrite(true);

                for (int i = 0; i < values.Length; i++)
                {
                    buffer.Add(values[i]); // TODO: have an AddRange method here
                }

                // we did read something
                return(true);
            }
        }
Пример #18
0
        // run in ui thread
        private void OnFeatureRead(EyeRetrieveResult eyeRetrieveResult, PupilRetrieveResult pupilRetrieveResult)
        {
            double diff = (frameReadTime - startTime).TotalMilliseconds;

            if (startTime.Ticks == 0)
            {
                diff = 0;
            }
            if (diff > 15000)
            {
                Close();
                return;
            }
            double fps = diff.Equals(lastDiff) ? 0 : 1000 / (diff - lastDiff);

            lastDiff = diff;
            resultWindow.UpdateFPS(fps);
            if (eyeRetrieveResult.HasLeftEye)
            {
                double x_rato = (double)pupilRetrieveResult.LeftPupil.X / img_width;
                leftData.Add(x_rato);
                double y_rato = 1 - (double)pupilRetrieveResult.LeftPupil.Y / img_height;
                leftTopData.Add(y_rato);
                OnLeftPupil(diff, x_rato, y_rato);
            }
            if (eyeRetrieveResult.HasRightEye)
            {
                double x_rato = (double)pupilRetrieveResult.RightPupil.X / img_width;
                rightData.Add(x_rato);
                double y_rato = 1 - (double)pupilRetrieveResult.RightPupil.Y / img_height;
                rightTopData.Add(y_rato);
                OnRightPupil(diff, x_rato, y_rato);
            }
        }
Пример #19
0
        protected override void OnStartEmit()
        {
            lastPosition  = m_transform.position;
            distanceMoved = 0.0f;
            controlPoints = new RingBuffer <AdditionalPoint>(maxPointNumber);
            controlPoints.Add(new AdditionalPoint {
                position = lastPosition
            });

            switch (parameter.orientationType)
            {
            case TrailOrientation.LookAt:
                controlPoints[0].forward = (parameter.lookAt.position - controlPoints[0].position).normalized;
                break;

            case TrailOrientation.Local:
                controlPoints[0].forward = transform.forward;
                break;

            case TrailOrientation.World:
                controlPoints[0].forward = parameter.forwardOverride;
                break;

            default:
                break;
            }

            AddPoint(new TrailPoint(), lastPosition);
            AddControlPoint(lastPosition);
        }
Пример #20
0
 private void populateBuffer(int elements, RingBuffer <int> buffer)
 {
     for (int i = 0; i < elements; i++)
     {
         buffer.Add(i);
     }
 }
Пример #21
0
    private static void HandleLog(string logString, string stackTrace, LogType type)
    {
        ConsoleLog log = new ConsoleLog(logString, stackTrace, type);

        Logs.Add(log);
        Viewer.UpdateView();
    }
Пример #22
0
 public virtual void SendByte(byte Data, bool RaiseEvent = true)
 {
     SendBuffer.Add(Data);
     if (RaiseEvent)
     {
         DataSent?.Invoke(this);
     }
 }
Пример #23
0
    public void Update()
    {
        valueBuffer.Add(InputManager.activeDevice.GetButton(buttonType));

        DownSide = state && (state != previousState);

        previousState = state;
    }
Пример #24
0
 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.");
     }
 }
Пример #25
0
        public void Update(float added)
        {
            //Add a value and get back the value we removed (or null)
            var removed = _buffer.Add(added);

            //Keep a running total of what we have in the window
            UpdateSums(removed, added);
        }
Пример #26
0
 public void ClearTest_notempty()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(7);
     Assert.IsFalse(rb.IsEmpty);
     rb.Clear();
     Assert.IsTrue(rb.IsEmpty);
 }
Пример #27
0
        protected override void Append(LoggingEvent loggingEvent)
        {
            string text = RenderLoggingEvent(loggingEvent);

            _buffer.Add(new ColoredItem(GetIndexForLevel(loggingEvent.Level), text));

            _bufferedInvoker.Invoke();
        }
Пример #28
0
        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);
        }
    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);
    }
 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();
 }
        public override void Update(PhysicalHeliState startState, PhysicalHeliState endState, JoystickOutput output, TimeSpan startTime, TimeSpan endTime)
        {
            PhysicalHeliState stateToMeasure = endState;

            // TODO Fill XYZ magnetic readings
            // TODO Simulate sensor lag, inaccuarcy, noise..
            _sampleHistory.Add(stateToMeasure.Axes);

            CurrentMeasuredAxes = IsPerfect ? stateToMeasure.Axes : ComputeMeanAxes();
        }
Пример #32
0
        public void RemoveAfter()
        {
            var target = new RingBuffer <int> {
                10, 20, 30, 40
            };

            target.RemoveAfter(target.BottomIndex);
            Assert.AreEqual(3, target.Count);
            Assert.AreEqual(10, target[target.TopIndex]);
            Assert.AreEqual(20, target[target.TopIndex.Next]);
            Assert.AreEqual(30, target[target.TopIndex.Next.Next]);
            target.RemoveAfter(target.BottomIndex.Previous);
            Assert.AreEqual(1, target.Count);
            Assert.AreEqual(10, target[target.TopIndex]);
            target.Add(100);
            target.Add(200);
            target.RemoveAfter(target.TopIndex);
            Assert.AreEqual(0, target.Count);
        }
Пример #33
0
        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.");
            }
        }
Пример #34
0
        public void Update()
        {
            var timestamp = Stopwatch.GetTimestamp();
            var interval  = timestamp - _lastTimestamp;

            lock (_window)
            {
                _window.Add(interval);
                _lastTimestamp = timestamp;
            }
        }
Пример #35
0
        public float[] GetValues(FilterParameters frame)
        {
            // step 1: accumulate over frequency range
            float current = 0f;

            for (int i = FreqStart; i < FreqStart + FreqCount; i++)
            {
                current += frame.Spectrum[i];
            }
            current /= (float)FreqCount;
            current  = current.NormDB();

            buffer.Add(current);

            // step 2: maintain a long-term average
            avg_long = AvgLowpass.Mix(current, avg_long);

            // step 3: get a recent moving average
            float lowpass = buffer.Last().Take(8).Average();

            // step 4: peak tracker
            max = Math.Max(Threshold, Math.Max(max, lowpass));

            // step 5: state transition
            if (!state)
            {
                if (lowpass > Trigger.Mix(avg_long, max))
                {
                    state = !state;
                    activation_rising_edge = 1f;
                }
            }
            else
            {
                // while we're high, bring the avg up faster
                avg_long = AvgLowpassHigh.Mix(current, avg_long);

                // on-state activation
                activation_high = 1f;

                if (lowpass < avg_long)
                {
                    state = !state;
                }
            }

            output[OUT_EDGE]       = activation_rising_edge;
            output[OUT_LEVEL]      = activation_high;
            activation_rising_edge = Math.Max(0f, activation_rising_edge - ActivationLinearDecay);
            activation_high        = Math.Max(0f, activation_high - ActivationLinearDecay);
            max *= Decay;

            return(output);
        }
Пример #36
0
        protected void ReadAllData()
        {
            if (Transport == null)
            {
                return;
            }

            while (Transport.BytesWaiting > 0)
            {
                dataBuffer.Add(Transport.Read());
            }
        }
Пример #37
0
            private RingBuffer <List <Peak> > peakHistory; // a FIFO list of peak lists

            public PeakHistory(int length, int maxPeaksPerFrame)
            {
                indexHistory = new RingBuffer <int>(length);
                peakHistory  = new RingBuffer <List <Peak> >(length);

                // Instantiate peak lists for later reuse
                for (int i = 0; i < length; i++)
                {
                    indexHistory.Add(-1);
                    peakHistory.Add(new List <Peak>(maxPeaksPerFrame));
                }
            }
Пример #38
0
 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);
 }
Пример #39
0
        /// <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);
            }
        }
Пример #40
0
 public void QueueTest_2()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(5);
     rb.Add(8);
     int d1 = rb.Remove();
     int d2 = rb.Remove();
     Assert.AreEqual(5, d1);
     Assert.AreEqual(8, d2);
 }
Пример #41
0
 public void IsFullTest_False_2()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(4);
     Assert.IsFalse(rb.IsFull);
 }
Пример #42
0
 public void IsEmptyTest_False()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(4);
     Assert.IsFalse(rb.IsEmpty);
 }
Пример #43
0
 public void QueueTest_1()
 {
     RingBuffer<int> rb = new RingBuffer<int>(4);
     rb.Add(3);
     int d = rb.Remove();
     Assert.AreEqual(3, d);
 }
Пример #44
0
 private void populateBuffer(int elements, RingBuffer<int> buffer) {
     for(int i = 0; i < elements; i++) {
         buffer.Add(i);
     }
 }
Пример #45
0
        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);

        }
Пример #46
0
 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);
 }
Пример #47
0
 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);
 }