larbin中hash函数

/* return a hashcode for this url */
uint url::hashCode () {
  unsigned int h=port;
  unsigned int i=0;
  while (host[i] != 0) {
	h = 31*h + host[i];
    i++;
  }
  i=0;
  while (file[i] != 0) {
	h = 31*h + file[i];
    i++;
  }
  return h % hashSize;
}
另一个简单的hash
static uint siteHashCode (char *host) {
  uint h=0;
  uint i=0;
  while (host[i] != 0) {
	h = 37*h + host[i];
    i++;
  }
  return h % namedSiteListSize;
}

你可能感兴趣的:(File,url)