⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hash.c

📁 vc环境下的pgp源码
💻 C
字号:
/*++
/* NAME
/*	hash 3
/* SUMMARY
/*	compute hash value for string
/* SYNOPSIS
/*	int hash(string, size)
/*	char *string;
/*	int size;
/* DESCRIPTION
/*	This function computes for the given null-terminated string an
/*	integer hash value in the range 0..size-1.
/* SEE ALSO
/* .fi
/*	Alfred V. Aho, Ravi Sethi and Jeffrey D. Ullman: Compilers: 
/*	principles, techniques and tools; Addison-Wesley, Amsterdam, 1986.
/* AUTHOR(S)
/*	Wietse Venema
/*	Eindhoven University of Technology
/*	Department of Mathematics and Computer Science
/*	Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
/*
/*	Originally written by: P. J. Weinberger at Bell Labs.
/* LAST MODIFICATION
/*	92/01/15 21:53:12
/* VERSION/RELEASE
/*	%I
/*--*/

static char hash_sccsid[] = "@(#) hash.c 1.1 92/01/15 21:53:12";

/* hash - hash a string; original author: P. J. Weinberger at Bell Labs. */

int     hash(s, size)
register char *s;
unsigned size;
{
    register unsigned long h = 0;
    register unsigned long g;

    /*
     * For a performance comparison with the hash function presented in K&R,
     * first edition, see the "Dragon" book by Aho, Sethi and Ullman.
     */

    while (*s) {
	h = (h << 4) + *s++;
	if (g = (h & 0xf0000000)) {
	    h ^= (g >> 24);
	    h ^= g;
	}
    }
    return (h % size);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -