FileDocCategorySizeDatePackage
BloomFilterAddOnly.javaAPI DocAzureus 3.0.3.42496Thu Feb 09 19:42:48 GMT 2006com.aelitis.azureus.core.util.bloom.impl

BloomFilterAddOnly

public class BloomFilterAddOnly extends BloomFilterImpl

Fields Summary
private byte[]
map
Constructors Summary
public BloomFilterAddOnly(int _max_entries)

		super( _max_entries );
			
		map	= new byte[(getMaxEntries()+7)/8];
	
Methods Summary
protected intdecValue(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 intgetValue(int index)

		byte	b = map[index/8];
			
		return(((b>>(index%8))&0x01));

	
protected intincValue(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 voidsetValue(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 inttrimValue(int value)

		if ( value < 0 ){
			return( 0 );
		}else if ( value > 1 ){
			return( 1);
		}else{
			return( value );
		}