private static int [ ] trickyGetPairsFromWindow ( final byte [ ] window , final int k , final int numPairsToGet , final int emptySpace ) { final int outputLength = emptySpace + numPairsToGet ; final int [ ] pairs = new int [ outputLength ] ; int rowIndex = 0 ; int pairIndex = emptySpace ; for ( rowIndex = 0 ; rowIndex < k ; rowIndex ++ ) { int wByte = window [ rowIndex ] & 0XFF ; while ( wByte != 0 ) { final int colIndex = Integer . numberOfTrailingZeros ( wByte ) ; // assert (colIndex < 8); wByte ^= ( 1 << colIndex ) ; // erase the 1 pairs [ pairIndex ++ ] = ( rowIndex << 6 ) | colIndex ; } } assert ( pairIndex == outputLength ) ; return ( pairs ) ; }
will be filled in later by the caller .