- packagecom.eshore.sweetop.dataframe;
- importcom.eshore.sweetop.data.KeyData;
- /*
- *linearprobing
- *Note:secondarychustering
- */
- publicclassLineOpenHashextendsOpenHash{
- publicLineOpenHash(intsize){
- super(size);
- }
- @Override
- publicinthash(intk,inti){
- return(multihash(k)+i)%table.length;
- }
- publicintmultihash(intk){
- doubled=k*0.6180339887;
- inta=(int)Math.floor(table.length*(d-(newDouble(d).intValue())));
- returna;
- }
- publicstaticvoidmain(String[]args){
- OpenHashoh=newLineOpenHash(10);
- oh.insert(newKeyData(1));
- oh.insert(newKeyData(2));
- oh.insert(newKeyData(3));
- oh.insert(newKeyData(14));
- KeyDatak=oh.search(2);
- System.out.println(k);
- }
- }