Beispiel #1
0
trieNode childRevTrie(revtrie T, trieNode i, uint depth, byte c, 
                      trieNode *lzl, trieNode *lzr)
 { 
    trieNode j;
    trieNode jlz;
    uint d,pos,jid;
    byte tc; uint *data;
    lztrie LZT = T->trie;
#ifdef QUERYREPORT
    BCALLS++;
#endif
    j = i+1;
#ifdef QUERYREPORT
    DEPTH1 += depth;
#endif
    data = T->data;
    while (!bitget1(data,j)) { // there is a child here
       pos = leftrankRevTrie(T,j); 
       jid = rthRevTrie(T,pos); // leftmost id in subtree
       jlz = NODE(LZT,jid);
       for (d=depth;d;d--) jlz = parentLZTrie(LZT,jlz);
#ifdef QUERYREPORT
       RJUMPS++;
       DEPTH += depth;
#endif
       tc = letterLZTrie(LZT,jlz);
       if (tc > c) break;
       if (tc == c) {
          *lzl = jlz; 
          if ((pos < T->n-1) && (rthRevTrie(T,pos+1)==jid)
	  /*(isemptyRevTrie(T,j))*/) { // empty
             pos = rightrankRevTrie(T,j); 
             jlz = NODE(LZT,rthRevTrie(T,pos)); // rightmost
             for (d=depth;d;d--) jlz = parentLZTrie(LZT,jlz);
             *lzr = jlz;
          }
          else *lzr = NULLT;
          return j; 
       }
       j = findclose(T->pdata,j)+1;
    }
    *lzl = *lzr = NULLT;
    return NULLT; // no child to go down by c
 }
Beispiel #2
0
uint idRevTrie(revtrie T, trieNode i)
 { 
    uint pos = leftrankRevTrie(T,i);
    return rthRevTrie(T,pos);
 }