Ejemplo n.º 1
0
static int
allprefixed_traverse(uint8*top,
int(*handle)(const char*,void*),void*arg){
/*26:*/
#line 578 "./critbit.w"

if(1&(intptr_t)top){
critbit0_node*q= (void*)(top-1);
for(int direction= 0;direction<2;++direction)
switch(allprefixed_traverse(q->child[direction],handle,arg)){
case 1:break;
case 0:return 0;
default:return-1;
}
return 1;
}

/*:26*/
#line 522 "./critbit.w"

/*27:*/
#line 595 "./critbit.w"

return handle((const char*)top,arg);/*:27*/
#line 523 "./critbit.w"

}
Ejemplo n.º 2
0
int critbitAllPrefixed(critbit_t *t, const char *prefix,
                       int(*handle)(const char *, void *, void *),
                       void *arg) {
    const uint8_t *ubytes = (void*)prefix;
    const size_t ulen = strlen(prefix);
    uint8_t *p = t->root;
    uint8_t *top = p;
    void *data = t->data;
    size_t i;

    if(!p) {
        return 1;
    }

    while(1 & (intptr_t)p) {
        critbit_node *q = (void*)(p - 1);
        uint8_t c = 0;
        if(q->byte < ulen)
        {
            c = ubytes[q->byte];
        }
        const int direction = (1 + (q->otherbits | c)) >> 8;
        p = q->child[direction];
        if(q->byte < ulen) {
            top = p;
            data = q->data[direction];
        }
    }

    for(i = 0; i < ulen; i++) {
        if(p[i] != ubytes[i])
        {
            return 1;
        }
    }

    return allprefixed_traverse(top, data, handle, arg);
}
Ejemplo n.º 3
0
int
critbit0_allprefixed(critbit0_tree*t,const char*prefix,
int(*handle)(const char*,void*),void*arg){
const uint8*ubytes= (void*)prefix;
const size_t ulen= strlen(prefix);
uint8*p= t->root;
uint8*top= p;

if(!p)return 1;
/*24:*/
#line 549 "./critbit.w"

while(1&(intptr_t)p){
critbit0_node*q= (void*)(p-1);
uint8 c= 0;
if(q->byte<ulen)c= ubytes[q->byte];
const int direction= (1+(q->otherbits|c))>>8;
p= q->child[direction];
if(q->byte<ulen)top= p;
}

/*:24*/
#line 535 "./critbit.w"

/*25:*/
#line 565 "./critbit.w"

for(size_t i= 0;i<ulen;++i){
if(p[i]!=ubytes[i])return 1;
}

/*:25*/
#line 536 "./critbit.w"


return allprefixed_traverse(top,handle,arg);
}
Ejemplo n.º 4
0
static int allprefixed_traverse(uint8_t *top, void *data,
                                int(*handle)(const char *, void *, void *),
                                void *arg) {
    int direction;
    
    if(1 & (intptr_t)top) {
        critbit_node *q = (void *)(top - 1);
        for(direction = 0; direction < 2; direction++) {
            switch(allprefixed_traverse(q->child[direction],
                                        q->data[direction],
                                        handle, arg)) {
                case 1:
                    break;
                case 0:
                    return 0;
                default:
                    return -1;
            }
        }
        return 1;
    }

    return handle((const char *)top, data, arg);
}