public int nextClearBit ( final int i ) { int x = i >> 6 ; // i / 64 with sign extension long w = ~ bitmap . get ( x ) ; w >>>= i ; if ( w != 0 ) { return i + numberOfTrailingZeros ( w ) ; } int length = bitmap . limit ( ) ; for ( ++ x ; x < length ; ++ x ) { long map = ~ bitmap . get ( x ) ; if ( map != 0L ) { return x * 64 + numberOfTrailingZeros ( map ) ; } } return MAX_CAPACITY ; }
Find the index of the next clear bit greater or equal to i .