lztrie loadLZTrie(FILE *f) { lztrie T; uint i,*ids; unsigned long long aux; T = malloc (sizeof(struct slztrie)); // loads n, the number of nodes in LZTrie if (fread(&T->n,sizeof(uint),1,f) != 1) { fprintf(stderr,"Error: Cannot read LZTrie from file\n"); exit(1); } // loads the parentheses structure of LZTrie T->pdata = loadParentheses(f, 2*T->n,true); T->data = T->pdata->data; // loads the letters labeling the edges of the trie, in preorder T->letters = malloc(T->n*sizeof(byte)); if (fread(T->letters,sizeof(byte),T->n,f) != T->n) { fprintf(stderr,"Error: Cannot read LZTrie from file\n"); exit(1); } T->ids = loadPerm(f); // boost first access T->boost = malloc(256*sizeof(trieNode)); for (i=0;i<256;i++) T->boost[i] = NULLT; i = 1; // shortcut for first child of root while (i != 2*T->n-1) { // shortcut for its closing parenthesis T->boost[T->letters[i-rank(T->pdata->bdata,i)]] = i; // shortcut for leftrankLZTrie i = findclose(T->pdata,i)+1; } return T; }
PermutationMRRR * PermutationMRRR::load(istream & fp) { uint rd = loadValue<uint>(fp); if(rd!=MRRRPERM) return NULL; PermutationMRRR * ret = new PermutationMRRR(); ret->permutation = loadPerm(fp); return ret; }
revtrie loadRevTrie(FILE *f, lztrie trie) { revtrie T; uint *emptybmap, *id; unsigned long long aux; T = malloc(sizeof(struct srevtrie)); if (fread(&T->n,sizeof(uint),1,f) != 1) { fprintf(stderr,"Error: Cannot read RevTrie from file\n"); exit(1); } T->pdata = loadParentheses(f, 2*T->n,false); T->data = T->pdata->data; // loads the bitstring indicating the empty nodes emptybmap = malloc(((T->n+W-1)/W)*sizeof(uint)); if (fread(emptybmap,sizeof(uint),(T->n+W-1)/W,f) != (T->n+W-1)/W) { fprintf(stderr,"Error: Cannot read RevTrie from file\n"); exit(1); } // creates, from the above bitstring, the bitmap indicating the empty nodes T->B = loadBitmap(f,T->n,emptybmap); T->nbits = bits(T->n-1); T->trie = trie; // loads the array of elements of the id permutation if (fread(&PARAMETER_T_RIDS,sizeof(uint),1,f) != 1) { fprintf(stderr,"Error: Cannot read RevTrie from file\n"); exit(1); } T->rids = loadPerm(f); T->rids->t = PARAMETER_T_RIDS; return T; }
static_permutation_mrrr * static_permutation_mrrr::load(FILE *fp) { uint rd; if(fread(&rd,sizeof(uint),1,fp)!=1) return NULL; if(rd!=STATIC_PERMUTATION_MRRR_HDR) return NULL; static_permutation_mrrr * ret = new static_permutation_mrrr(); ret->permutation = loadPerm(fp); return ret; }