3
<!-- @(#) $Revision: 4.8 $ $Source: /cvsroot/judy/doc/ext/Judy1_funcs_3.htm,v $ --->
4
<TITLE>Judy1_funcs(3)</TITLE>
7
<TABLE border=0 width="100%"><TR>
8
<TD width="40%" align="left">Judy1_funcs(3)</TD>
9
<TD width="10%" align="center"> </TD>
10
<TD width="40%" align="right">Judy1_funcs(3)</TD>
18
C library for creating and accessing a dynamic array of bits, using
19
any value of a word as an index
22
<DT><B>SYNOPSIS</B></DT>
25
int <A href="#Judy1Set" >Judy1Set</A>( PPvoid_t PPJ1Array, Word_t Index, PJError_t PJError);
26
int <A href="#Judy1Unset" >Judy1Unset</A>( PPvoid_t PPJ1Array, Word_t Index, PJError_t PJError);
27
int <A href="#Judy1Test" >Judy1Test</A>( Pcvoid_t PJ1Array, Word_t Index, PJError_t PJError);
28
Word_t <A href="#Judy1Count" >Judy1Count</A>( Pcvoid_t PJ1Array, Word_t Index1, Word_t Index2, PJError_t PJError);
29
int <A href="#Judy1ByCount" >Judy1ByCount</A>( Pcvoid_t PJ1Array, Word_t Nth, Word_t * PIndex, PJError_t PJError);
30
Word_t <A href="#Judy1FreeArray" >Judy1FreeArray</A>( PPvoid_t PPJ1Array, PJError_t PJError);
31
Word_t <A href="#Judy1MemUsed" >Judy1MemUsed</A>( Pcvoid_t PJ1Array);
32
int <A href="#Judy1First" >Judy1First</A>( Pcvoid_t PJ1Array, Word_t * PIndex, PJError_t PJError);
33
int <A href="#Judy1Next" >Judy1Next</A>( Pcvoid_t PJ1Array, Word_t * PIndex, PJError_t PJError);
34
int <A href="#Judy1Last" >Judy1Last</A>( Pcvoid_t PJ1Array, Word_t * PIndex, PJError_t PJError);
35
int <A href="#Judy1Prev" >Judy1Prev</A>( Pcvoid_t PJ1Array, Word_t * PIndex, PJError_t PJError);
36
int <A href="#Judy1FirstEmpty">Judy1FirstEmpty</A>(Pcvoid_t PJ1Array, Word_t * PIndex, PJError_t PJError);
37
int <A href="#Judy1NextEmpty" >Judy1NextEmpty</A>( Pcvoid_t PJ1Array, Word_t * PIndex, PJError_t PJError);
38
int <A href="#Judy1LastEmpty" >Judy1LastEmpty</A>( Pcvoid_t PJ1Array, Word_t * PIndex, PJError_t PJError);
39
int <A href="#Judy1PrevEmpty" >Judy1PrevEmpty</A>( Pcvoid_t PJ1Array, Word_t * PIndex, PJError_t PJError);
43
<DT><B>DESCRIPTION</B></DT>
45
A macro equivalent exists for each function call.
46
Because the macro forms are sometimes faster and have a simpler error
47
handling interface than the equivalent functions,
48
they are the preferred way of calling the Judy1 functions.
49
See <A href="Judy1_3.htm">Judy1(3)</A>
51
The function call definitions are included here for completeness.
53
One of the difficulties in using the Judy1 function calls lies in
54
determining whether to pass a pointer or the address of a pointer.
55
Since the functions that modify the Judy1 array must also modify the
56
pointer to the Judy1 array, you must pass the address of the pointer
57
rather than the pointer itself.
58
This often leads to hard-to-debug programmatic errors.
59
In practice, the macros allow the compiler to catch programming
60
errors when pointers instead of addresses of pointers are passed.
62
The Judy1 function calls have an additional parameter beyond
63
those specified in the macro calls. This parameter is either a
64
pointer to an error structure, or <B>NULL</B> (in which case the
65
detailed error information is not returned).
67
In the following descriptions, the functions are described in
68
terms of how the macros use them (only in the case of
69
<B>#define JUDYERROR_NOTEST 1</B>). This is the suggested use
70
of the macros after your program has been fully debugged.
71
When the <B>JUDYERROR_NOTEST</B> macro is not specified,
72
an error structure is declared to store error information
73
returned from the Judy1 functions when an error occurs.
75
Notice the placement of the <B>&</B> in the different functions.
78
<DT><A name="Judy1Set"><B>Judy1Set(&PJ1Array, Index, &JError)</B></A></DT>
81
#define J1S(Rc_int, PJ1Array, Index) \
82
Rc_int = Judy1Set(&PJ1Array, Index, PJE0)
86
<DT><A name="Judy1Unset"><B>Judy1Unset(&PJ1Array, Index, &JError)</B></A></DT>
89
#define J1U(Rc_int, PJ1Array, Index) \
90
Rc_int = Judy1Unset(&PJ1Array, Index, PJE0)
94
<DT><A name="Judy1Test"><B>Judy1Test(PJ1Array, Index, &JError)</B></A></DT>
97
#define J1T(Rc_int, PJ1Array, Index) \
98
Rc_int = Judy1Test(PJ1Array, Index, PJE0)
102
<DT><A name="Judy1Count"><B>Judy1Count(PJ1Array, Index1, Index2, &JError)</B></A></DT>
105
#define J1C(Rc_word, PJ1Array, Index1, Index2) \
106
Rc_word = Judy1Count(PJ1Array, Index1, Index2, PJE0)
109
A return value of 0 can be an error, valid as a count, or it can indicate a special case
110
for a fully-populated array (32-bit machines only). If necessary, the following
111
code can be used to disambiguate this return:
115
Rc_word = Judy1Count(PJ1Array, Index1, Index2, &JError);
118
if (JU_ERRNO(&JError) == JU_ERRNO_NONE)
119
printf("Judy1 array population == 0\n");
120
if (JU_ERRNO(&JError) == JU_ERRNO_FULL)
121
printf("Judy1 array population == 2^32\n");
122
if (JU_ERRNO(&JError) == JU_ERRNO_NULLPPARRAY)
124
if (JU_ERRNO(&JError) > JU_ERRNO_NFMAX)
125
goto Null_or_CorruptArray;
129
<DT><A name="Judy1ByCount"><B>Judy1ByCount(PJ1Array, Nth, &Index, &JError)</B></A></DT>
132
#define J1BC(Rc_int, PJ1Array, Nth, Index) \
133
Rc_int = Judy1ByCount(PJ1Array, Nth, &Index, PJE0)
137
<DT><A name="Judy1FreeArray"><B>Judy1FreeArray(&PJ1Array, &JError)</B></A></DT>
140
#define J1FA(Rc_word, PJ1Array) \
141
Rc_word = Judy1FreeArray(&PJ1Array, PJE0)
145
<DT><A name="Judy1MemUsed"><B>Judy1MemUsed(PJ1Array)</B></A></DT>
148
#define J1MU(Rc_word, PJ1Array) \
149
Rc_word = Judy1MemUsed(PJ1Array)
153
<DT><A name="Judy1First"><B>Judy1First(PJ1Array, &Index, &JError)</B></A></DT>
156
#define J1F(Rc_int, PJ1Array, Index) \
157
Rc_int = Judy1First(PJ1Array, &Index, PJE0)
161
<DT><A name="Judy1Next"><B>Judy1Next(PJ1Array, &Index, &JError)</B></A></DT>
164
#define J1N(Rc_int, PJ1Array, Index) \
165
Rc_int = Judy1Next(PJ1Array, &Index, PJE0)
169
<DT><A name="Judy1Last"><B>Judy1Last(PJ1Array, &Index, &JError)</B></A></DT>
172
#define J1L(Rc_int, PJ1Array, Index) \
173
Rc_int = Judy1Last(PJ1Array, &Index, PJE0)
177
<DT><A name="Judy1Prev"><B>Judy1Prev(PJ1Array, &Index, &JError)</B></A></DT>
180
#define J1P(Rc_int, PJ1Array, Index) \
181
Rc_int = Judy1Prev(PJ1Array, &Index, PJE0)
185
<DT><A name="Judy1FirstEmpty"><B>Judy1FirstEmpty(PJ1Array, &Index, &JError)</B></A></DT>
188
#define J1FE(Rc_int, PJ1Array, Index) \
189
Rc_int = Judy1FirstEmpty(PJ1Array, &Index, PJE0)
193
<DT><A name="Judy1NextEmpty"><B>Judy1NextEmpty(PJ1Array, &Index, &JError)</B></A></DT>
196
#define J1NE(Rc_int, PJ1Array, Index) \
197
Rc_int = Judy1NextEmpty(PJ1Array, &Index, PJE0)
201
<DT><A name="Judy1LastEmpty"><B>Judy1LastEmpty(PJ1Array, &Index, &JError)</B></A></DT>
204
#define J1LE(Rc_int, PJ1Array, Index) \
205
Rc_int = Judy1LastEmpty(PJ1Array, &Index, PJE0)
209
<DT><A name="Judy1PrevEmpty"><B>Judy1PrevEmpty(PJ1Array, &Index, &JError)</B></A></DT>
212
#define J1PE(Rc_int, PJ1Array, Index) \
213
Rc_int = Judy1PrevEmpty(PJ1Array, &Index, PJE0)
218
Definitions for all of the Judy functions, the types
232
are provided in the <B>Judy.h</B> header file
233
(/usr/include/Judy.h).
234
<B>Note</B>: Callers should define Judy1 arrays as type <B>Pvoid_t</B>,
235
which can be passed by value to functions that take
236
<B>Pcvoid_t</B> (constant <B>Pvoid_t</B>),
237
and also by address to functions that take <B>PPvoid_t</B>.
240
<DT><B>AUTHOR</B></DT>
242
Judy was invented by Doug Baskins and implemented by Hewlett-Packard.
245
<DT><B>SEE ALSO</B></DT>
247
<A href="Judy_3.htm">Judy(3)</A>,
248
<A href="JudyL_3.htm">JudyL(3)</A>,
249
<A href="JudySL_3.htm">JudySL(3)</A>,
250
<A href="JudyHS_3.htm">JudyHS(3)</A>,
255
<A href="http://judy.sourceforge.net">
256
http://judy.sourceforge.net</A>,
257
for more information and Application Notes.