Ejemplo n.º 1
0
        public CircularArray <T> Grow(long bottom, long top)
        {
            var grow = new CircularArray <T> (baseSize + 1);

            for (long i = top; i < bottom; i++)
            {
                grow[i] = this[i];
            }

            return(grow);
        }
Ejemplo n.º 2
0
        public CircularArray <T> Grow(int bottom, int top)
        {
            var grow = new CircularArray <T> (baseSize + 1);

            for (int i = top; i < bottom; i++)
            {
                grow.segment[i] = segment[i % size];
            }

            return(grow);
        }
Ejemplo n.º 3
0
        public void PushBottom(T obj)
        {
            int b = bottom;
            var a = array;

            var size = b - top - upperBound;

            if (size > a.Size)
            {
                upperBound = top;
                a          = a.Grow(b, upperBound);
                array      = a;
            }

            a.segment[b % a.size] = obj;
            Interlocked.Increment(ref bottom);
        }
Ejemplo n.º 4
0
        public void PushBottom(T obj)
        {
            int b = bottom;
            var a = array;

            // Take care of growing
            var size = b - top - upperBound;

            if (size > a.Size)
            {
                upperBound = top;
                a          = a.Grow(b, upperBound);
                array      = a;
            }

            // Register the new value
            a.segment[b % a.size] = obj;
            CustomInterlocked.Increment(ref bottom);
        }