public Position get(int pos) {while(pos >= nextPos) {if (count == positions.length) {Position[] newPositions = new Position[ArrayUtil.oversize(1+count, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];System.arraycopy(positions, nextWrite, newPositions, 0, positions.length-nextWrite);System.arraycopy(positions, 0, newPositions, positions.length-nextWrite, nextWrite);for(int i=positions.length;i<newPositions.length;i++) {newPositions[i] = new Position();}nextWrite = positions.length;positions = newPositions;}if (nextWrite == positions.length) {nextWrite = 0;}assert positions[nextWrite].count == 0;positions[nextWrite++].pos = nextPos++;count++;}assert inBounds(pos);final int index = getIndex(pos);assert positions[index].pos == pos;return positions[index];}

public Position Get(int pos){while (pos >= nextPos){if (count == positions.Length){Position[] newPositions = new Position[ArrayUtil.Oversize(1 + count, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];System.Array.Copy(positions, nextWrite, newPositions, 0, positions.Length - nextWrite);System.Array.Copy(positions, 0, newPositions, positions.Length - nextWrite, nextWrite);for (int i = positions.Length; i < newPositions.Length; i++){newPositions[i] = new Position();}nextWrite = positions.Length;positions = newPositions;}if (nextWrite == positions.Length){nextWrite = 0;}Debug.Assert(positions[nextWrite].count == 0);positions[nextWrite++].pos = nextPos++;count++;}Debug.Assert(InBounds(pos));int index = GetIndex(pos);Debug.Assert(positions[index].pos == pos);return positions[index];}
