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); }
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); }
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); }
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); }