void getheadstringstree(Suffixtree *stree,Stringtype *str) { Branchinfo branchinfo; Reference ref; if(stree->headend == NULL) { str->length = stree->headnodedepth; if(stree->headnodedepth > 0) { getbranchinfostree(stree,ACCESSHEADPOS,&branchinfo,stree->headnode); str->start = branchinfo.headposition; } else { str->start = 0; } } else { str->length = stree->headnodedepth + (Uint) (stree->headend-stree->headstart+1); int2ref(stree,&ref,stree->insertnode); if(ref.toleaf) { str->start = LEAFADDR2NUM(stree,ref.address); } else { getbranchinfostree(stree,ACCESSHEADPOS,&branchinfo,ref.address); str->start = branchinfo.headposition; } } }
void getleafinfostree(Suffixtree *stree,Leafinfo *leafinfo,Lref lptr) { Uint node = LEAFBROTHERVAL(*lptr); if(NILPTR(node)) { leafinfo->address = NULL; } else { int2ref(stree,leafinfo,node); } }
static void TestObjectRef(skiatest::Reporter* reporter) { SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1)); SkAutoTUnref<SkPDFInt> int2(new SkPDFInt(2)); SkAutoTUnref<SkPDFObjRef> int2ref(new SkPDFObjRef(int2.get())); SkPDFCatalog catalog((SkPDFDocument::Flags)0); catalog.addObject(int1.get(), false); catalog.addObject(int2.get(), false); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int1.get()) == 3); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int2.get()) == 3); char expectedResult[] = "2 0 R"; SkDynamicMemoryWStream buffer; int2ref->emitObject(&buffer, &catalog, false); REPORTER_ASSERT(reporter, buffer.getOffset() == strlen(expectedResult)); REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult, buffer.getOffset())); }
void getbranchinfostree(Suffixtree *stree,Uint whichinfo, Branchinfo *branchinfo,Bref btptr) { Uint which = whichinfo, node, distance, *largeptr; if(which & ACCESSSUFFIXLINK) { which |= ACCESSDEPTH; } if(which & (ACCESSDEPTH | ACCESSHEADPOS)) { if(stree->chainstart != NULL && btptr >= stree->chainstart) { distance = DIVBYSMALLINTS((Uint) (stree->nextfreebranch - btptr)); branchinfo->depth = stree->currentdepth + distance; branchinfo->headposition = stree->nextfreeleafnum - distance; } else { if(ISLARGE(*btptr)) { if(which & ACCESSDEPTH) { branchinfo->depth = GETDEPTH(btptr); } if(which & ACCESSHEADPOS) { branchinfo->headposition = GETHEADPOS(btptr); } } else { distance = GETDISTANCE(btptr); GETCHAINEND(largeptr,btptr,distance); if(which & ACCESSDEPTH) { branchinfo->depth = GETDEPTH(largeptr) + distance; } if(which & ACCESSHEADPOS) { branchinfo->headposition = GETHEADPOS(largeptr) - distance; } } } } if(which & ACCESSSUFFIXLINK) { if((stree->chainstart != NULL && btptr >= stree->chainstart) || !ISLARGE(*btptr)) { branchinfo->suffixlink = btptr + SMALLINTS; } else { branchinfo->suffixlink = stree->branchtab + getlargelinkstree(stree,btptr,branchinfo->depth); } /*SHOWINDEX((Uint) BRADDR2NUM(stree,btptr)); fprintf(stdout,"(%u) --> ", GETDEPTH(btptr)); SHOWINDEX((Uint) BRADDR2NUM(stree,branchinfo->suffixlink)); fprintf(stdout," (%u)\n", GETDEPTH(branchinfo->suffixlink));*/ } if(which & ACCESSFIRSTCHILD) { int2ref(stree,&(branchinfo->firstchild),GETCHILD(btptr)); } if(which & ACCESSBRANCHBROTHER) { node = GETBROTHER(btptr); if(NILPTR(node)) { branchinfo->branchbrother.address = NULL; } else { int2ref(stree,&(branchinfo->branchbrother),node); } } }