nl_tokens: Write out up to max words returns how many were written
pl_tokens: protected static long discharge ( final BitmapStorage container , IteratingRLW i , long <mask> ) { long counter = 0 ; while ( i . size ( ) > 0 && counter < max ) { long l1 = i . getRunningLength ( ) ; if ( l1 > 0 ) { if ( l1 + counter > max ) l1 = max - counter ; container . addStreamOfEmptyWords ( i . getRunningBit ( ) , l1 ) ; counter += l1 ; } long l = i . getNumberOfLiteralWords ( ) ; if ( l + counter > max ) l = max - counter ; for ( int k = 0 ; k < l ; ++ k ) { container . addWord ( i . getLiteralWordAt ( k ) ) ; } counter += l ; i . discardFirstWords ( l + l1 ) ; } return counter ; }