public boolean fastGet ( int index ) { assert index >= 0 && index < numBits ; int i = index >> 6 ; // div 64 // signed shift will keep a negative index and force an // array-index-out-of-bounds-exception, removing the need for an explicit check. int bit = index & 0x3f ; // mod 64 long bitmask = 1L << bit ; return ( bits [ i ] & bitmask ) != 0 ; }
Returns true or false for the specified bit index . The index should be less than the OpenBitSet size