~ubuntu-branches/ubuntu/precise/judy/precise

« back to all changes in this revision

Viewing changes to src/Judy.h

  • Committer: Bazaar Package Importer
  • Author(s): Troy Heber
  • Date: 2007-05-21 15:07:50 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070521150750-khuc7e3iblyvi0a9
Tags: 1.0.5-1
* Fixed alignment issue, (Closes: #401124)
* Update packaging, policy, debhelper, etc.
* Removed old BIT cruft from rules
* Upstream has propper distclean target (Closes: #424425)

Show diffs side-by-side

added added

removed removed

Lines of Context:
220
220
// ****************************************************************************
221
221
// JUDY1 FUNCTIONS:
222
222
 
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);
246
244
 
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:
521
517
 
522
518
// This is a slower version with current processors, but in the future...
523
 
#ifdef notdef
524
 
#define J1T(Rc,PArray,Index)                                    \
525
 
{                                                               \
526
 
    PWord_t P_L  = (PWord_t)(PArray);                           \
527
 
    (Rc) = 0;                                                   \
528
 
    if (P_L)                    /* cannot be a NULL pointer */  \
529
 
    {                                                           \
530
 
        if (P_L[0] < 31)        /* is a LeafL  */               \
531
 
        {                                                       \
532
 
            Word_t  _pop1 = P_L[0] + 1;                         \
533
 
            PWord_t P_LE  = P_L    + _pop1;                     \
534
 
            Word_t  _index = 0;                                 \
535
 
            int ii = 0;                                         \
536
 
            P_L++;                                              \
537
 
            while (_pop1 > 4)                                   \
538
 
            {                                                   \
539
 
                _pop1 /=2;                                      \
540
 
                _index = P_L[_pop1];                            \
541
 
                if ((Index) > _index) P_L += _pop1 + 1;         \
542
 
            }                                                   \
543
 
            while (P_L <= P_LE)                                 \
544
 
            {                                                   \
545
 
                ii++;                                           \
546
 
                _index = P_L[0];                                \
547
 
                if (_index >= (Index)) break;                   \
548
 
                P_L++;                                          \
549
 
            }                                                   \
550
 
            if (_index == (Index)) (Rc) = 1;                    \
551
 
        }                                                       \
552
 
        else                                                    \
553
 
        {                                                       \
554
 
            (Rc) = j__udy1Test((Pvoid_t)P_L, (Index));          \
555
 
        }                                                       \
556
 
    }                                                           \
557
 
}
558
 
#endif // notdef
559
519
 
560
 
#define J1T(Rc,PArray,Index)                                    \
561
 
{                                                               \
562
 
    PWord_t P_L  = (PWord_t)(PArray);                           \
563
 
    (Rc) = 0;                                                   \
564
 
    if (P_L)                    /* cannot be a NULL pointer */  \
565
 
    {                                                           \
566
 
        if (P_L[0] < 31)        /* is a LeafL  */               \
567
 
        {                                                       \
568
 
            Word_t  _pop1 = P_L[0] + 1;                         \
569
 
            Word_t  _EIndex = P_L[_pop1];                       \
570
 
            if (_pop1 >= 16)                                    \
571
 
            {                                                   \
572
 
                if ((Index) > P_L[_pop1/2]) P_L += _pop1/2;     \
573
 
            }                                                   \
574
 
            if ((Index) <= _EIndex)                             \
575
 
            {                                                   \
576
 
                while((Index) > *(++P_L));                      \
577
 
                if (*P_L == (Index)) (Rc) = 1;                  \
578
 
            }                                                   \
579
 
        }                                                       \
580
 
        else                                                    \
581
 
        {                                                       \
582
 
            (Rc) = j__udy1Test((Pvoid_t)P_L, Index);            \
583
 
        }                                                       \
584
 
    }                                                           \
585
 
}
 
520
#define J1T(Rc,PArray,Index)                                            \
 
521
    (Rc) = Judy1Test((Pvoid_t)(PArray), Index, PJE0)
586
522
 
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)
617
553
 
618
 
#define JLG(PV,PArray,Index)                                    \
619
 
{                                                               \
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 */  \
624
 
    {                                                           \
625
 
        if (P_L[0] < 31)        /* is a LeafL  */               \
626
 
        {                                                       \
627
 
            Word_t  _pop1 = P_L[0] + 1;                         \
628
 
            Word_t  _EIndex = P_L[_pop1];                       \
629
 
            Word_t  _off  = j__L_LeafWOffset[_pop1] - 1;        \
630
 
            if (_pop1 >= 16)                                    \
631
 
            {                                                   \
632
 
                if ((Index) > P_L[_pop1/2]) P_L += _pop1/2;     \
633
 
            }                                                   \
634
 
            if ((Index) <= _EIndex)                             \
635
 
            {                                                   \
636
 
                while((Index) > *(++P_L));                      \
637
 
                if (*P_L == (Index)) (PV) = (Pvoid_t)(P_L+_off);\
638
 
            }                                                   \
639
 
        }                                                       \
640
 
        else                                                    \
641
 
        {                                                       \
642
 
            (PV) = (Pvoid_t)j__udyLGet((Pvoid_t)P_L, Index);    \
643
 
        }                                                       \
644
 
    }                                                           \
645
 
}
 
554
#define JLG(PV,PArray,Index)                                            \
 
555
    (PV) = (Pvoid_t)JudyLGet((Pvoid_t)PArray, Index, PJE0)
646
556
 
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")
658
568
 
659
 
#define JLN(PV,PArray,Index)                                    \
660
 
{                                                               \
661
 
    extern const uint8_t j__L_LeafWOffset[];                    \
662
 
    PWord_t P_L  = (PWord_t) (PArray);                          \
663
 
                                                                \
664
 
    (PV) = (Pvoid_t) NULL;                                      \
665
 
                                                                \
666
 
    if (P_L)                    /* cannot be a NULL pointer */  \
667
 
    {                                                           \
668
 
        if (P_L[0] < 31)        /* is a LeafL  */               \
669
 
        {                                                       \
670
 
            Word_t _pop1 = P_L[0] + 1;                          \
671
 
            Word_t _off  = j__L_LeafWOffset[_pop1] -1;          \
672
 
            if ((Index) < P_L[_pop1])                           \
673
 
            {                                                   \
674
 
                while(1)                                        \
675
 
                {                                               \
676
 
                    if ((Index) < *(++P_L))                     \
677
 
                    {                                           \
678
 
                        (Index) = *P_L;                         \
679
 
                        (PV) = (Pvoid_t) (P_L + _off);          \
680
 
                        break;                                  \
681
 
                    }                                           \
682
 
                }                                               \
683
 
            }                                                   \
684
 
        }                                                       \
685
 
        else                                                    \
686
 
        {                                                       \
687
 
            (PV) = (Pvoid_t)JudyLNext((Pvoid_t) PArray, &(Index), PJE0); \
688
 
        }                                                       \
689
 
    }                                                           \
690
 
}
 
569
#define JLN( PV,    PArray,   Index)                                    \
 
570
        J_1P(PV,    PArray, &(Index), JudyLNext, "JudyLNext")
691
571
 
692
572
#define JLL( PV,    PArray,   Index)                                    \
693
573
        J_1P(PV,    PArray, &(Index), JudyLLast,  "JudyLLast")