public static long materialize(final IteratingRLW32 i, final BitmapStorage32 c, int max) {
        final int origMax = max;
        while (true) {
            if (i.getRunningLength() > 0) {
                int l = i.getRunningLength();
                if (l > max)
                    l = max;
                c.addStreamOfEmptyWords(i.getRunningBit(), l);
                max -= l;
            }
            long L = i.getNumberOfLiteralWords();
            for (int k = 0; k < L; ++k)
                c.addWord(i.getLiteralWordAt(k));
            if (max > 0) {
                if (!i.next())
                    break;
            } else
                break;
        }
        return origMax - max;
    }
public static long materialize(final IteratingRLW32 i, final BitmapStorage32 c, int max) {
        final int origMax = max;
        while (true) {
            if (i.getRunningLength() > 0) {
                int l = i.getRunningLength();
                if (l > max)
                    l = max;
                c.addStreamOfEmptyWords(i.getRunningBit(), l);
                max -= l;
            }
            long L = i.getNumberOfLiteralWords();
            for (int k = 0; k < L; ++k)
                c.addWord(i.getLiteralWordAt(k));
            if (max > 0) {
                if (!i.next())
                    break;
            } else
                break;
        }
        return origMax - max;
    }
public static long materialize ( final IteratingRLW32 i , final BitmapStorage32 c , int max ) { final int origMax = max ; while ( true ) { if ( i . getRunningLength ( ) > 0 ) { int l = i . getRunningLength ( ) ; if ( l > max ) l = max ; c . addStreamOfEmptyWords ( i . getRunningBit ( ) , l ) ; max -= l ; } long L = i . getNumberOfLiteralWords ( ) ; for ( int k = 0 ; k < L ; ++ k ) c . addWord ( i . getLiteralWordAt ( k ) ) ; if ( max > 0 ) { if ( ! i . next ( ) ) break ; } else break ; } return origMax - max ; }
Turn an iterator into a bitmap

@param i   iterator we wish to materialize
@param c   where we write
@param max maximum number of words to materialize
@return how many words were actually materialized
Turn an iterator into a bitmap