Programming with Judy

Using Judy
Chapter 326
Sorting As part of normal processing, Judy sorts indexes numerically using its
own, internal sorting criteria. Therefore, you cannot modify the sorting
order to include user-defined sorting criteria (such as requesting a sort
using multi-byte characters).
While Judy is not primarily intended as a sorting algorithm, in many
cases it's faster to store values in a Judy array and read them back in
sorted order than to sort them using standard sorting algorithms.
JudySL strings are treated as series of N-byte numbers (N = 4 on a 32-bit
system or 8 on a 64-bit system).
Keep in mind that Judy arrays do not support synonyms, that is multiple
values associated with the same index. The caller must build synonyms
outside of Judy; for instance, by having the Judy value (from JudyL or
JudySL) point to a linked list of nodes, each with a different value for the
same index.
Each index can only be stored once. If you store value xyz and then store
the value xyz again, Judy uses the same value area.
JudySL sorts two strings that start with the same prefix like sort(1) in
UNIX (but without multi-byte support):
gazelle
gazette
If one string is a substring of another, the shorter one is first:
gazelle
gazelle2
Count (between
two indexes)
Judy1Count JudyLCount
Count (locate the
Nth index within
an array, where
N=Count)
Judy1ByCount JudyLByCount
Free Array Judy1FreeArray JudyLFreeArray JudySLFreeArray
Table 3-1 A summary of Judy functions
Judy Array Type
Function Judy1: maps
ulong_t to bit
JudyL: maps
ulong_t to ulong_t
JudySL: maps
string to ulong_t