private void increaseLengthTo ( int index , int maxLength ) { if ( highestResultIndex > - 1 ) { int newResultsCount = Math . min ( index - highestResultIndex , maxLength ) ; if ( newResultsCount == maxLength ) { results . clear ( ) ; results . addAll ( Collections . < T > nCopies ( maxLength , null ) ) ; } else if ( newResultsCount > 0 ) { results . addAll ( Collections . < T > nCopies ( newResultsCount , null ) ) ; removeExceedingResults ( maxLength ) ; } } else { // First use of cache assert results . isEmpty ( ) : "Cache results list should be empty" ; results . addAll ( Collections . < T > nCopies ( Math . min ( index + 1 , maxLength ) , null ) ) ; } }
Increases the size of cached results buffer .