public void set ( int i , boolean value ) { int idx = i / 8 ; if ( idx >= bb . limit ( ) ) { throw new IndexOutOfBoundsException ( ) ; } int bit = 7 - ( i % 8 ) ; if ( value ) { bb . put ( idx , ( byte ) ( bb . get ( idx ) | MASKS [ bit ] ) ) ; } else { bb . put ( idx , ( byte ) ( bb . get ( idx ) & MASKSR [ bit ] ) ) ; } }
set the i th bit to 1 or 0