Ejemplo n.º 1
0
revtrie loadRevTrie (FILE *f, lztrie trie, nodemap map)

   { revtrie T;
     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->data = malloc (((2*T->n+W-1)/W)*sizeof(uint));
     if (fread (T->data,sizeof(uint),(2*T->n+W-1)/W,f) != (2*T->n+W-1)/W)
        { fprintf (stderr,"Error: Cannot read RevTrie from file\n");
          exit(1);
        }                                                                       
     T->pdata = createParentheses (T->data,2*T->n,false);
     T->nbits = bits(T->n-1);
     T->trie = trie;
     T->map = map;
     T->id = malloc (((T->n*T->nbits+W-1)/W)*sizeof(uint));
     if (fread (T->id,sizeof(uint),(T->n*T->nbits+W-1)/W,f) !=
                 (T->n*T->nbits+W-1)/W)
        { fprintf (stderr,"Error: Cannot read RevTrie from file\n");
          exit(1);
        }
     return T;
   }
Ejemplo n.º 2
0
revtrie createRevTrie(uint *string, lztrie trie, uint *emptybmap, uint n)
 { 
    revtrie T;
    uint i;
    T        = malloc(sizeof(struct srevtrie));
    T->data  = string;
    T->pdata = createParentheses(string,2*n,false,true);
    T->B     = createBitmap(emptybmap, n,false);
    T->n     = n;
    T->trie  = trie;
    return T;
 }
Ejemplo n.º 3
0
revtrie createRevTrie(uint *string, uint *id, lztrie trie, uint *emptybmap, uint n)
 { 
    revtrie T;
    uint i;
    T        = malloc(sizeof(struct srevtrie));
    T->data  = string;
    T->pdata = createParentheses(string,2*n,false,true);
    T->B     = createBitmap(emptybmap, n,false);
    T->n     = n;
    T->nbits = bits(trie->n-1);
    T->rids  = createPerm(id, trie->n, PARAMETER_T_RIDS);
    T->trie  = trie;
    return T;
 }
Ejemplo n.º 4
0
revtrie createRevTrie (uint *string, lztrie trie, nodemap map, uint *id, 
                       uint n)

   { revtrie T;
     uint i;
     T = malloc (sizeof(struct srevtrie));
     T->data = string;
     T->pdata = createParentheses (string,2*n,false);
     T->n = n;
     T->nbits = bits(n-1);
     T->trie = trie;
     T->map = map;
     T->id = malloc (((n*T->nbits+W-1)/W)*sizeof(uint));
     for (i=0;i<n;i++)
	bitput (T->id,i*T->nbits,T->nbits,id[i]);
     return T;
   }
Ejemplo n.º 5
0
Archivo: lztrie.c Proyecto: peper/pizza
lztrie createLZTrie(uint *string, byte *letters, uint *id, uint n)
 { 
    lztrie T;
    uint i;
    T          = malloc(sizeof(struct slztrie));
    T->data    = string;
    T->pdata   = createParentheses(string,2*n,true,true);
    T->n       = n;
    T->letters = letters;
    // creates the ids permutation
    T->ids     = createPerm(id, n, PARAMETER_T_IDS);
    // 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*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;
 }
Ejemplo n.º 6
0
Archivo: lztrie.c Proyecto: peper/pizza
lztrie loadLZTrie (FILE *f)

   { lztrie T;
     uint i;
     T = malloc (sizeof(struct slztrie));
     if (fread (&T->n,sizeof(uint),1,f) != 1)
	{ fprintf (stderr,"Error: Cannot read LZTrie from file\n");
	  exit(1);
	}
     T->data = malloc (((2*T->n+W-1)/W)*sizeof(uint));
     if (fread (T->data,sizeof(uint),(2*T->n+W-1)/W,f) != (2*T->n+W-1)/W)
	{ fprintf (stderr,"Error: Cannot read LZTrie from file\n");
	  exit(1);
	}
     T->pdata = createParentheses (T->data,2*T->n,true);
     T->nbits = bits(T->n-1);
     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->id = malloc (((T->n*T->nbits+W-1)/W)*sizeof(uint));
     if (fread (T->id,sizeof(uint),(T->n*T->nbits+W-1)/W,f) != 
		 (T->n*T->nbits+W-1)/W)
	{ fprintf (stderr,"Error: Cannot read LZTrie from file\n");
	  exit(1);
	}
	// 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;
   }
Ejemplo n.º 7
0
revtrie loadRevTrie(FILE *f, lztrie trie)
 { 
    revtrie T;
    uint *emptybmap;
    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);
    }
    aux = (2*(unsigned long long)T->n+W-1)/W;
    T->data = malloc(aux*sizeof(uint));
    if (fread(T->data,sizeof(uint),aux,f) != aux) {
       fprintf (stderr,"Error: Cannot read RevTrie from file\n");
       exit(1);
    }                                                                       
    T->pdata = createParentheses(T->data,2*T->n,false,true);
    // 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 = createBitmap(emptybmap, T->n, false);
    T->nbits = bits(trie->n-1);
    aux = (((unsigned long long)trie->n)*trie->nbits+W-1)/W;
    T->rids_1 = malloc(aux*sizeof(uint));
    if (fread(T->rids_1,sizeof(uint),aux,f)!= aux) {
       fprintf(stderr,"Error: Cannot read RevTrie from file\n");
       exit(1);
    }
    
    T->trie = trie;
    return T;
 }
Ejemplo n.º 8
0
Archivo: lztrie.c Proyecto: peper/pizza
lztrie createLZTrie (uint *string, byte *letters, uint *id, uint n)

   { lztrie T;
     uint i;
     T = malloc (sizeof(struct slztrie));
     T->data = string;
     T->pdata = createParentheses (string,2*n,true);
     T->n = n;
     T->nbits = bits(n-1);
     T->letters = letters;
     T->id = malloc (((n*T->nbits+W-1)/W)*sizeof(uint));
     for (i=0;i<n;i++)
	bitput (T->id,i*T->nbits,T->nbits,id[i]);
	// 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*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;
   }