home *** CD-ROM | disk | FTP | other *** search
- /*
- * 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);
- }
-
-
-