int get ( int rowSize ) { if ( lookup . size ( ) == 0 ) { return - 1 ; } int index = lookup . findFirstGreaterEqualKeyIndex ( rowSize ) ; if ( index == - 1 ) { return - 1 ; } // statistics for successful requests only - to be used later for midSize requestCount ++ ; requestSize += rowSize ; int length = lookup . getValue ( index ) ; int difference = length - rowSize ; int key = lookup . getKey ( index ) ; lookup . remove ( index ) ; if ( difference >= midSize ) { int pos = key + ( rowSize / scale ) ; lookup . add ( pos , difference ) ; } else { lostFreeBlockSize += difference ; } return key ; }
Returns the position of a free block or 0 .