220
220
// ****************************************************************************
221
221
// JUDY1 FUNCTIONS:
223
extern int j__udy1Test( Pvoid_t Pjpm, Word_t Index);
224
223
extern int Judy1Test( Pcvoid_t PArray, Word_t Index, P_JE);
225
224
extern int Judy1Set( PPvoid_t PPArray, Word_t Index, P_JE);
226
225
extern int Judy1SetArray( PPvoid_t PPArray, Word_t Count,
236
235
extern Word_t Judy1MemActive( Pcvoid_t PArray);
237
236
extern int Judy1First( Pcvoid_t PArray, Word_t * PIndex, P_JE);
238
237
extern int Judy1Next( Pcvoid_t PArray, Word_t * PIndex, P_JE);
239
extern int j__udy1Next( Pvoid_t Pjpm, Word_t * PIndex);
240
238
extern int Judy1Last( Pcvoid_t PArray, Word_t * PIndex, P_JE);
241
239
extern int Judy1Prev( Pcvoid_t PArray, Word_t * PIndex, P_JE);
242
240
extern int Judy1FirstEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
244
242
extern int Judy1LastEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
245
243
extern int Judy1PrevEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
247
extern PPvoid_t j__udyLGet( Pvoid_t Pjpm, Word_t Index);
248
245
extern PPvoid_t JudyLGet( Pcvoid_t PArray, Word_t Index, P_JE);
249
246
extern PPvoid_t JudyLIns( PPvoid_t PPArray, Word_t Index, P_JE);
250
247
extern int JudyLInsArray( PPvoid_t PPArray, Word_t Count,
264
261
extern Word_t JudyLMemActive( Pcvoid_t PArray);
265
262
extern PPvoid_t JudyLFirst( Pcvoid_t PArray, Word_t * PIndex, P_JE);
266
263
extern PPvoid_t JudyLNext( Pcvoid_t PArray, Word_t * PIndex, P_JE);
267
extern PPvoid_t j__udyLNext( Pvoid_t Pjpm, Word_t * PIndex);
268
264
extern PPvoid_t JudyLLast( Pcvoid_t PArray, Word_t * PIndex, P_JE);
269
265
extern PPvoid_t JudyLPrev( Pcvoid_t PArray, Word_t * PIndex, P_JE);
270
266
extern int JudyLFirstEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
520
516
// with root-level leaves:
522
518
// This is a slower version with current processors, but in the future...
524
#define J1T(Rc,PArray,Index) \
526
PWord_t P_L = (PWord_t)(PArray); \
528
if (P_L) /* cannot be a NULL pointer */ \
530
if (P_L[0] < 31) /* is a LeafL */ \
532
Word_t _pop1 = P_L[0] + 1; \
533
PWord_t P_LE = P_L + _pop1; \
540
_index = P_L[_pop1]; \
541
if ((Index) > _index) P_L += _pop1 + 1; \
543
while (P_L <= P_LE) \
547
if (_index >= (Index)) break; \
550
if (_index == (Index)) (Rc) = 1; \
554
(Rc) = j__udy1Test((Pvoid_t)P_L, (Index)); \
560
#define J1T(Rc,PArray,Index) \
562
PWord_t P_L = (PWord_t)(PArray); \
564
if (P_L) /* cannot be a NULL pointer */ \
566
if (P_L[0] < 31) /* is a LeafL */ \
568
Word_t _pop1 = P_L[0] + 1; \
569
Word_t _EIndex = P_L[_pop1]; \
572
if ((Index) > P_L[_pop1/2]) P_L += _pop1/2; \
574
if ((Index) <= _EIndex) \
576
while((Index) > *(++P_L)); \
577
if (*P_L == (Index)) (Rc) = 1; \
582
(Rc) = j__udy1Test((Pvoid_t)P_L, Index); \
520
#define J1T(Rc,PArray,Index) \
521
(Rc) = Judy1Test((Pvoid_t)(PArray), Index, PJE0)
587
523
#define J1S( Rc, PArray, Index) \
588
524
J_1I(Rc, (&(PArray)), Index, Judy1Set, "Judy1Set")
615
551
#define J1MU(Rc, PArray) \
616
552
(Rc) = Judy1MemUsed(PArray)
618
#define JLG(PV,PArray,Index) \
620
extern const uint8_t j__L_LeafWOffset[]; \
621
PWord_t P_L = (PWord_t)(PArray); \
622
(PV) = (Pvoid_t) NULL; \
623
if (P_L) /* cannot be a NULL pointer */ \
625
if (P_L[0] < 31) /* is a LeafL */ \
627
Word_t _pop1 = P_L[0] + 1; \
628
Word_t _EIndex = P_L[_pop1]; \
629
Word_t _off = j__L_LeafWOffset[_pop1] - 1; \
632
if ((Index) > P_L[_pop1/2]) P_L += _pop1/2; \
634
if ((Index) <= _EIndex) \
636
while((Index) > *(++P_L)); \
637
if (*P_L == (Index)) (PV) = (Pvoid_t)(P_L+_off);\
642
(PV) = (Pvoid_t)j__udyLGet((Pvoid_t)P_L, Index); \
554
#define JLG(PV,PArray,Index) \
555
(PV) = (Pvoid_t)JudyLGet((Pvoid_t)PArray, Index, PJE0)
647
557
#define JLI( PV, PArray, Index) \
648
558
J_1P(PV, (&(PArray)), Index, JudyLIns, "JudyLIns")
656
566
#define JLF( PV, PArray, Index) \
657
567
J_1P(PV, PArray, &(Index), JudyLFirst, "JudyLFirst")
659
#define JLN(PV,PArray,Index) \
661
extern const uint8_t j__L_LeafWOffset[]; \
662
PWord_t P_L = (PWord_t) (PArray); \
664
(PV) = (Pvoid_t) NULL; \
666
if (P_L) /* cannot be a NULL pointer */ \
668
if (P_L[0] < 31) /* is a LeafL */ \
670
Word_t _pop1 = P_L[0] + 1; \
671
Word_t _off = j__L_LeafWOffset[_pop1] -1; \
672
if ((Index) < P_L[_pop1]) \
676
if ((Index) < *(++P_L)) \
679
(PV) = (Pvoid_t) (P_L + _off); \
687
(PV) = (Pvoid_t)JudyLNext((Pvoid_t) PArray, &(Index), PJE0); \
569
#define JLN( PV, PArray, Index) \
570
J_1P(PV, PArray, &(Index), JudyLNext, "JudyLNext")
692
572
#define JLL( PV, PArray, Index) \
693
573
J_1P(PV, PArray, &(Index), JudyLLast, "JudyLLast")