myhashfunction.java
来自「用java编写的hashtable程序」· Java 代码 · 共 24 行
JAVA
24 行
/**
A class for determining the index of a word using unicode
Written by : H Yu
*/
public class MyHashFunction {
/**
*class method returns the index of word w
*@param w word
*/
public static int HashFunction(String w,int d) {
String word = w;
int l = word.length();
int sum=0;
for (int i=0;i<l;i++) {
char ch = word.charAt(i);
int value = Character.getNumericValue(ch);
sum+=value;
}
return(sum%d);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?