private void ensureCapacity(int segmentIndex) {
        while(segmentIndex >= segments.length) {
            segments = Arrays.copyOf(segments, segments.length * 3 / 2);
        }

        long numSegmentsPopulated = length >> log2OfSegmentSize;

        for(long i=numSegmentsPopulated; i <= segmentIndex; i++) {
            segments[(int)i] = memoryPool.getSegment();
            length += 1 << log2OfSegmentSize;
        }
    }
private void ensureCapacity ( int segmentIndex ) { while ( segmentIndex >= segments . length ) { segments = Arrays . copyOf ( segments , segments . length * 3 / 2 ) ; } long numSegmentsPopulated = length > > log2OfSegmentSize ; for ( long i = numSegmentsPopulated ; i <= segmentIndex ; i ++ ) { segments [ ( int ) i ] = memoryPool . getSegment ( ) ; length += 1 << log2OfSegmentSize ; } }
Ensures that the segment at segmentIndex exists

@param segmentIndex