Programming with Judy

Using Judy
Using JudyL
Chapter 3 41
(void) printf(" %ld unique values from %8x - %8x\n",
JudyLCount(PJArray, Index, Index + histo_incr, &JError),
Index, Index + histo_incr);
Index += histo_incr + 1;
}
// PRINT MEAN (average),
// MEDIAN (middle value, or average of two middle values)
// RANGE (low and high value)
tmp1 = (ulong_t)(ran_sum/(long long)num_vals);
(void) printf(" mean: 0x%08x\n", tmp1);
// If there were an even number of randoms generated, then average
// the two middle numbers. Otherwise, the mean is the middle value
if (num_vals & 1)
{
JudyLByCount(PJArray, num_vals/2, &tmp1, &JError);
JudyLByCount(PJArray, (num_vals/2)+1, &tmp2, &JError);
median = (tmp1 + tmp2) / 2;
}
else
{
JudyLByCount(PJArray, (num_vals+1)/2, &median, &JError);
}
(void) printf(" median: 0x%08x\n", median);
Index = 0;
JudyLFirst(PJArray, &Index, 0);
(void) printf("first random generated: 0x%08x\n", Index);