/* 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 */
|