1Judy1_funcs(3)             Library Functions Manual             Judy1_funcs(3)
2
3
4

NAME

6       Judy1  functions - C library for creating and accessing a dynamic array
7       of bits, using any value of a word as an index
8

SYNOPSIS

10       int    Judy1Set(       PPvoid_t PPJ1Array, Word_t   Index,  PJError_t PJError);
11       int    Judy1Unset(     PPvoid_t PPJ1Array, Word_t   Index,  PJError_t PJError);
12       int    Judy1Test(      Pcvoid_t  PJ1Array, Word_t   Index,  PJError_t PJError);
13       Word_t Judy1Count(     Pcvoid_t  PJ1Array, Word_t   Index1, Word_t    Index2, PJError_t PJError);
14       int    Judy1ByCount(   Pcvoid_t  PJ1Array, Word_t   Nth,    Word_t * PIndex,  PJError_t PJError);
15       Word_t Judy1FreeArray( PPvoid_t PPJ1Array, PJError_t PJError);
16       Word_t Judy1MemUsed(   Pcvoid_t  PJ1Array);
17       int    Judy1First(     Pcvoid_t  PJ1Array, Word_t * PIndex, PJError_t PJError);
18       int    Judy1Next(      Pcvoid_t  PJ1Array, Word_t * PIndex, PJError_t PJError);
19       int    Judy1Last(      Pcvoid_t  PJ1Array, Word_t * PIndex, PJError_t PJError);
20       int    Judy1Prev(      Pcvoid_t  PJ1Array, Word_t * PIndex, PJError_t PJError);
21       int    Judy1FirstEmpty(Pcvoid_t  PJ1Array, Word_t * PIndex, PJError_t PJError);
22       int    Judy1NextEmpty( Pcvoid_t  PJ1Array, Word_t * PIndex, PJError_t PJError);
23       int    Judy1LastEmpty( Pcvoid_t  PJ1Array, Word_t * PIndex, PJError_t PJError);
24       int    Judy1PrevEmpty( Pcvoid_t  PJ1Array, Word_t * PIndex, PJError_t PJError);
25

DESCRIPTION

27       A macro equivalent exists for each function call.   Because  the  macro
28       forms  are sometimes faster and have a simpler error handling interface
29       than the equivalent functions, they are the preferred  way  of  calling
30       the  Judy1 functions.  See Judy1(3) for more information.  The function
31       call definitions are included here for completeness.
32
33       One of the difficulties in using the Judy1 function calls lies  in  de‐
34       termining whether to pass a pointer or the address of a pointer.  Since
35       the functions that modify the Judy1 array must also modify the  pointer
36       to  the  Judy1  array,  you must pass the address of the pointer rather
37       than the pointer itself.  This often leads  to  hard-to-debug  program‐
38       matic errors.  In practice, the macros allow the compiler to catch pro‐
39       gramming errors when pointers instead  of  addresses  of  pointers  are
40       passed.
41
42       The  Judy1  function  calls  have  an additional parameter beyond those
43       specified in the macro calls.  This parameter is either a pointer to an
44       error  structure, or NULL (in which case the detailed error information
45       is not returned).
46
47       In the following descriptions, the functions are described in terms  of
48       how  the  macros use them (only in the case of #define JUDYERROR_NOTEST
49       1).  This is the suggested use of the macros  after  your  program  has
50       been fully debugged.  When the JUDYERROR_NOTEST macro is not specified,
51       an error structure is declared to store error information returned from
52       the Judy1 functions when an error occurs.
53
54       Notice the placement of the & in the different functions.
55
56        Judy1Set(&PJ1Array, Index, &JError)
57
58                      #define J1S(Rc_int, PJ1Array, Index) \
59                         Rc_int = Judy1Set(&PJ1Array, Index, PJE0)
60
61        Judy1Unset(&PJ1Array, Index, &JError)
62
63                      #define J1U(Rc_int, PJ1Array, Index) \
64                         Rc_int = Judy1Unset(&PJ1Array, Index, PJE0)
65
66        Judy1Test(PJ1Array, Index, &JError)
67
68                      #define J1T(Rc_int, PJ1Array, Index) \
69                         Rc_int = Judy1Test(PJ1Array, Index, PJE0)
70
71        Judy1Count(PJ1Array, Index1, Index2, &JError)
72
73                      #define J1C(Rc_word, PJ1Array, Index1, Index2) \
74                         Rc_word = Judy1Count(PJ1Array, Index1, Index2, PJE0)
75
76                      A  return  value of 0 can be an error, valid as a count,
77                      or it can indicate a special case for a  fully-populated
78                      array (32-bit machines only).  If necessary, the follow‐
79                      ing code can be used to disambiguate this return:
80
81                      JError_t JError;
82
83                      Rc_word = Judy1Count(PJ1Array, Index1, Index2, &JError);
84                      if (Rc_word == 0)
85                      {
86                          if (JU_ERRNO(&JError) == JU_ERRNO_NONE)
87                              printf("Judy1 array population == 0\n");
88                          if (JU_ERRNO(&JError) == JU_ERRNO_FULL)
89                              printf("Judy1 array population == 2^32\n");
90                          if (JU_ERRNO(&JError) == JU_ERRNO_NULLPPARRAY)
91                              goto NullArray;
92                          if (JU_ERRNO(&JError) >  JU_ERRNO_NFMAX)
93                              goto Null_or_CorruptArray;
94                      }
95
96        Judy1ByCount(PJ1Array, Nth, &Index, &JError)
97
98                      #define J1BC(Rc_int, PJ1Array, Nth, Index) \
99                         Rc_int = Judy1ByCount(PJ1Array, Nth, &Index, PJE0)
100
101        Judy1FreeArray(&PJ1Array, &JError)
102
103                      #define J1FA(Rc_word, PJ1Array) \
104                         Rc_word = Judy1FreeArray(&PJ1Array, PJE0)
105
106        Judy1MemUsed(PJ1Array)
107
108                      #define J1MU(Rc_word, PJ1Array) \
109                         Rc_word = Judy1MemUsed(PJ1Array)
110
111        Judy1First(PJ1Array, &Index, &JError)
112
113                      #define J1F(Rc_int, PJ1Array, Index) \
114                         Rc_int = Judy1First(PJ1Array, &Index, PJE0)
115
116        Judy1Next(PJ1Array, &Index, &JError)
117
118                      #define J1N(Rc_int, PJ1Array, Index) \
119                         Rc_int = Judy1Next(PJ1Array, &Index, PJE0)
120
121        Judy1Last(PJ1Array, &Index, &JError)
122
123                      #define J1L(Rc_int, PJ1Array, Index) \
124                         Rc_int = Judy1Last(PJ1Array, &Index, PJE0)
125
126        Judy1Prev(PJ1Array, &Index, &JError)
127
128                      #define J1P(Rc_int, PJ1Array, Index) \
129                         Rc_int = Judy1Prev(PJ1Array, &Index, PJE0)
130
131        Judy1FirstEmpty(PJ1Array, &Index, &JError)
132
133                      #define J1FE(Rc_int, PJ1Array, Index) \
134                         Rc_int = Judy1FirstEmpty(PJ1Array, &Index, PJE0)
135
136        Judy1NextEmpty(PJ1Array, &Index, &JError)
137
138                      #define J1NE(Rc_int, PJ1Array, Index) \
139                         Rc_int = Judy1NextEmpty(PJ1Array, &Index, PJE0)
140
141        Judy1LastEmpty(PJ1Array, &Index, &JError)
142
143                      #define J1LE(Rc_int, PJ1Array, Index) \
144                         Rc_int = Judy1LastEmpty(PJ1Array, &Index, PJE0)
145
146        Judy1PrevEmpty(PJ1Array, &Index, &JError)
147
148                      #define J1PE(Rc_int, PJ1Array, Index) \
149                         Rc_int = Judy1PrevEmpty(PJ1Array, &Index, PJE0)
150
151       Definitions for all of the Judy functions, the types Pvoid_t, Pcvoid_t,
152       PPvoid_t,  Word_t,  JError_t, and PJError_t, the constants NULL, JU_ER‐
153       RNO_*, JERR, and PJE0, are provided in the Judy.h header file (/usr/in‐
154       clude/Judy.h).   Note:   Callers  should  define  Judy1  arrays as type
155       Pvoid_t, which can be passed by value to functions that  take  Pcvoid_t
156       (constant  Pvoid_t),  and  also  by  address  to  functions  that  take
157       PPvoid_t.
158

AUTHOR

160       Judy was invented by Doug Baskins and implemented by Hewlett-Packard.
161

SEE ALSO

163       Judy(3), JudyL(3), JudySL(3), JudyHS(3),
164       malloc(),
165       the Judy website, http://judy.sourceforge.net, for more information and
166       Application Notes.
167
168
169
170                                                                Judy1_funcs(3)
Impressum