Methods Summary |
---|
protected int | decValue(int index)returns the value BEFORE decrement
int original_value = getValue( index );
if ( original_value <= 0 ){
return( 0 );
}
setValue( index, (byte)(original_value-1) );
return( original_value );
|
protected int | getValue(int index)
byte b = map[index/8];
return(((b>>(index%8))&0x01));
|
protected int | incValue(int index)returns the value BEFORE increment
int original_value = getValue( index );
if ( original_value >= 1 ){
return( 1 );
}
setValue( index, (byte)(original_value+1) );
return( original_value );
|
private void | setValue(int index, byte value)
byte b = map[index/8];
if ( value == 0 ){
// b = (byte)(b&~(0x01<<(index%8)));
throw( new RuntimeException( "remove not supported" ));
}else{
b = (byte)(b|(0x01<<(index%8)));
}
// System.out.println( "setValue[" + index + "]:" + Integer.toHexString( map[index/2]&0xff) + "->" + Integer.toHexString( b&0xff ));
map[index/8] = b;
|
protected int | trimValue(int value)
if ( value < 0 ){
return( 0 );
}else if ( value > 1 ){
return( 1);
}else{
return( value );
}
|