public void writeVarShort ( final short value , int optimal ) throws IOException { if ( value < 0 ) throw new IllegalArgumentException ( ) ; int [ ] varShortDepths = { optimal , 16 } ; final int bitLength = new Bits ( value ) . bitLength ; int type = Arrays . binarySearch ( varShortDepths , bitLength ) ; if ( type < 0 ) { type = - type - 1 ; } this . write ( new Bits ( type , 1 ) ) ; this . write ( new Bits ( value , varShortDepths [ type ] ) ) ; }
Write var short .