Exemplo n.º 1
0
unsigned HashTable::hash(const void *key, int ksize) const
{
   unsigned h = 0x811C9DC5;
   unsigned char *bp = (unsigned char *) key;
   if (ksize<=0)
   {
      if (ksize==PSTRINGDATA) {
        ksize = (*(unsigned char*)key)+1;
        goto BlockHash;
      }
      if (ksize<0) {
        h = hashc(bp,-ksize,h);
        bp -= ksize;
      }
      unsigned char* ks = bp;
      while (*bp) bp++;
      if (ignorecase)
        h = hashnc(ks,(size32_t)(bp-ks),h);
      else
        h = hashc(ks,(size32_t)(bp-ks),h);
   }
   else
   {
BlockHash:
      if (ignorecase)
        h = hashnc(bp,ksize,h);
      else
        h = hashc(bp,ksize,h);
   }
      //Strings that only differ by a single character don't generate hashes very far apart without this
   h *= 0x01000193;
   //h = ((h << 7) ^ (h >> 25));
   return h;
}
Exemplo n.º 2
0
 inline unsigned getHashFromFindParam(const void *fp) const
 {
     return hashnc((const unsigned char *)fp, strlen((const char *)fp), 0);
 }
Exemplo n.º 3
0
 CThorNodeGroup(const char* _groupName, unsigned _nodeCount, bool _replicateOutputs)
     : groupName(_groupName), nodeCount(_nodeCount), replicateOutputs(_replicateOutputs)
 {
     keyhash = hashnc((const byte *)groupName.get(),groupName.length(),0);
     timeCached = msTick();
 }