Plan 9 from Bell Labs’s /usr/web/sources/contrib/mycroftiv/unreleased/hashfuncs/prihashdem.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/* given a number representing hashtable size and additional data arguments, prihashdem will produce correctly sized hashes based on simple prime number based algorithm */
/* EXAMPLE: prihashdem 1000 foo bar baz */

#include <u.h>
#include <libc.h>
#include <ctype.h>
#include "prihash.h"

void
main(int argc, char **argv)
{
	uint ntbl;
	uint hashout;

	if((argc < 3) || (isdigit(*(argv[1])) == 0)){
		print("usage: prihashdem tablesize hashme1 [hashme2] [hashme3] ... \n");
		exits(nil);
	}

	ntbl = atoi(argv[1]);

	for(int i = 2; i < argc; i++){
		hashout = prihash(ntbl, argv[i]);
		print("%s : %ud\n", argv[i], hashout);
	}
	exits(nil);
}

/* implemented by mycroftiv */

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].