4
main() // Simple JudyL demo, see "run_demo" script; @(#) $Revision: 4.4 $
6
Pvoid_t Parray = (Pvoid_t) NULL; // empty JudyL array.
7
Word_t * Pvalue; // value for one index.
8
char line[BUFSIZ]; // input line.
9
Word_t index; // in JudyL array.
11
printf("Interactive Judy demo program to input, sort, and list numbers.\n"
12
"Enter a number: "); // fflush(stdout); ?
14
while (fgets(line, BUFSIZ, stdin)) // input.
16
index = strtoul(line, NULL, 0); // note: bad input => 0.
17
JLI(Pvalue, Parray, index); // insert index in JudyL array.
18
++(*Pvalue); // count duplicates.
20
printf(" Index Dups\n"); // print all saved indexes:
21
index = 0; // start search at zero.
22
JLF(Pvalue, Parray, index); // find first saved index.
24
while (Pvalue != NULL)
26
printf("%12lu %5lu\n", index, *Pvalue);
27
JLN(Pvalue, Parray, index); // find next saved index.
29
printf("Next: "); // fflush(stdout); ?