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 }
inline uint NODE(lzindex I, uint id) { if (!id) return 0; return Rev(I, getposRevTrie(I.bwdtrie,leftrankRevTrie(I.bwdtrie, RNODE(I,id)))); }
uint rthRevTrie(revtrie T, uint pos) { uint nbits = T->trie->nbits; return rthLZTrie(T->trie,bitget(T->R,getposRevTrie(T,pos)*nbits,nbits)); }
uint rthRevTrie(revtrie T, uint pos) { return rthLZTrie(T->trie, leftrankLZTrie(T->trie,mapto(T->Rev,getposRevTrie(T,pos)))); }
uint rthRevTrie(revtrie T, uint pos) { return RIDS(T,getposRevTrie(T,pos)); //bitget(T->id,getposRevTrie(T,pos)*T->nbits,T->nbits); }