算法之双重散列

  1. packagecom.eshore.sweetop.dataframe;
  2. importjava.math.BigInteger;
  3. importcom.eshore.sweetop.data.KeyData;
  4. publicclassDoubleOpenHashextendsOpenHash{
  5. publicDoubleOpenHash(intsize){
  6. //super((int)Math.pow(2,((int)(Math.log(size)/Math.log(2)))+1));
  7. super(newBigInteger(String.valueOf(size)).nextProbablePrime().intValue());
  8. System.out.println(table.length);
  9. }
  10. publicinthash(intk,inti){
  11. return(multihash1(k)+i*multihash2(k))%table.length;
  12. }
  13. publicintmultihash1(intk){
  14. returnk%table.length;
  15. }
  16. publicintmultihash2(intk){
  17. returnk%table.length+1;
  18. }
  19. publicstaticvoidmain(String[]args){
  20. OpenHashoh=newDoubleOpenHash(6);
  21. oh.insert(newKeyData(1));
  22. oh.insert(newKeyData(2));
  23. oh.insert(newKeyData(3));
  24. oh.insert(newKeyData(14));
  25. oh.insert(newKeyData(15));
  26. KeyDatak=oh.search(2);
  27. System.out.println(k);
  28. }
  29. }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值