File: McHashTable.cpp

package info (click to toggle)
doc%2B%2B 3.2-1
  • links: PTS
  • area: non-free
  • in suites: slink
  • size: 1,844 kB
  • ctags: 1,925
  • sloc: cpp: 16,762; lex: 2,938; makefile: 278; java: 273; yacc: 139; perl: 20; sh: 17
file content (49 lines) | stat: -rw-r--r-- 948 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/////////////////////////////////////////////////////////////////
//
// $Id: McHashTable.cpp,v 3.0 1997/02/04 17:48:57 bzfzoeck Exp $
//
// $Log: McHashTable.cpp,v $
// Revision 3.0  1997/02/04 17:48:57  bzfzoeck
// released Version 3.0
//
// Revision 1.2  1996/12/16 10:44:50  bzfzoeck
// now really
//
// Revision 1.1  1996/10/12  20:43:27  bzfzoeck
// Ist auch im mclib repository drin !
//
// Revision 1.1  1996/07/17  15:27:06  bzfstall
// Hash table added.
//
//
/////////////////////////////////////////////////////////////////
#include "McHashTable.h"

// One word summary of a string. This is taken from Tcl.

int hash(const char* str)
{
    int result = 0;
    while (1) {
	char c = *str++;
	if (c == 0) break;
	result += (result<<3) + c;
    }
    return result;
}

int hash(int i)
{
    return i;
}

int compare(const char* str1, const char* str2)
{
    return strcmp(str1,str2);
}

int compare(int i1, int i2)
{
    return i1 - i2;
}