home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics 16,000
/
graphics-16000.iso
/
msdos
/
utils
/
graphtal.lzh
/
Graphtal.Amiga
/
Hash.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-17
|
984b
|
44 lines
/*
* Hash.C - character based hashing functions.
*
* Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
* University of Berne, Switzerland
* All rights reserved.
*
* This software may be freely copied, modified, and redistributed
* provided that this copyright notice is preserved on all copies.
*
* You may not distribute this software, in whole or in part, as part of
* any commercial product without the express consent of the authors.
*
* There is no warranty or other guarantee of fitness of this software
* for any purpose. It is provided solely "as is".
*
*/
#include "Hash.h"
// string hashing by P.J. Weinberger
unsigned int hash(const char* s)
{
unsigned int h=0;
unsigned int g;
for (register int i=0; s[i] != '\0'; i++) {
h = (h<<4) + s[i];
if (g = h & 0xf0000000)
{
h = h^(g>>24);
h = h^g;
}
}
return h;
}
unsigned int hash(const char* s, long arg)
{
return ((hash(s)<<5)+arg);
}