Пример #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
 }
Пример #2
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;
#ifdef QUERYREPORT
    BCALLS++;
#endif
    j = i+1;
#ifdef QUERYREPORT
    DEPTH1 += depth;
#endif
    while (!bitget1(T->data,j)) { // there is a child here
       pos = leftrankRevTrie(T,j); 
       jlz = mapto(T->Rev, getposRevTrie(T,pos));
       for (d=depth;d;d--) jlz = parentLZTrie(T->trie,jlz);
#ifdef QUERYREPORT
       RJUMPS++;
       DEPTH += depth;
#endif
       tc = letterLZTrie(T->trie,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 = mapto(T->Rev, getposRevTrie(T,pos));
             for (d=depth;d;d--) jlz = parentLZTrie(T->trie,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
 }
Пример #3
0
inline uint NODE(lzindex I, uint id)
 {
    if (!id) return 0;
    return Rev(I, getposRevTrie(I.bwdtrie,leftrankRevTrie(I.bwdtrie, RNODE(I,id))));
 }
Пример #4
0
bool isemptyRevTrie(revtrie T, trieNode i)
 {
    return !bitget1(T->B->data, leftrankRevTrie(T,i));
 }
Пример #5
0
uint idRevTrie(revtrie T, trieNode i)
 { 
    uint pos = leftrankRevTrie(T,i);
    return rthRevTrie(T,pos);
 }