- packagecom.eshore.sweetop.dataframe;
- importjava.math.BigInteger;
- importcom.eshore.sweetop.data.KeyData;
- publicclassDoubleOpenHashextendsOpenHash{
- publicDoubleOpenHash(intsize){
- //super((int)Math.pow(2,((int)(Math.log(size)/Math.log(2)))+1));
- super(newBigInteger(String.valueOf(size)).nextProbablePrime().intValue());
- System.out.println(table.length);
- }
- publicinthash(intk,inti){
- return(multihash1(k)+i*multihash2(k))%table.length;
- }
- publicintmultihash1(intk){
- returnk%table.length;
- }
- publicintmultihash2(intk){
- returnk%table.length+1;
- }
- publicstaticvoidmain(String[]args){
- OpenHashoh=newDoubleOpenHash(6);
- oh.insert(newKeyData(1));
- oh.insert(newKeyData(2));
- oh.insert(newKeyData(3));
- oh.insert(newKeyData(14));
- oh.insert(newKeyData(15));
- KeyDatak=oh.search(2);
- System.out.println(k);
- }
- }