Programming with Judy
Example of a Multi-dimensional Array
Example Code
Chapter 4 53
assert (PPArray != PPVNULL);
assert (Index != PCNULL);
while (TRUE) // until return.
{
WORDCPY (& indexword, pos);
if ((PPvalue = JudyLIns (PPArray, indexword, PJError)) == PPJERR)
return (PPVNULL); // Index cannot be stored.
if (LASTWORD (indexword))
return (PPvalue); // is value for whole Index string.
pos += WORDSIZE;
PPArray = PPvalue; // each value -> next array.
}
/*NOTREACHED*/
} // JudySLIns()
In summary
This chapter contains an example that illustrates a Judy
multi-dimensional array. Excellent memory efficiency makes
multi-dimensional arrays a practical application of the Judy
technology that may be “best in class”.