java - Hash Table With Coalesced Hashing Instead of Quadratic Probing -
i working on taking hashset class using quadratic probing , trying make use coalesced hashing instead. new hashing concept of coalesced hashing confusing me. @ moment working add , remove methods.
add:
public boolean add( anytype x ) { int currentpos = findpos( x ); if( isactive( array, currentpos ) ) return false; if( array[ currentpos ] == null ) occupied++; array[ currentpos ] = new hashentry( x, true ); currentsize++; modcount++; if( occupied > array.length / 2 ) rehash( ); return true; }
and remove:
public boolean remove( object x ) { int currentpos = findpos( x ); if( !isactive( array, currentpos ) ) return false; array[ currentpos ].isactive = false; currentsize--; modcount++; if( currentsize < array.length / 8 ) rehash( ); return true; }
i understand how coalesced hashing works on paper when inserting table. other lost on how implement in java.
any appreciated! thank you!
Comments
Post a Comment