4 int no_pertenece(char *z, char c, int len);
6 void pop_front(char *z, unsigned int pos);
8 int get_pos(char *z, int len, char c);
9 /****fin privadas******/
11 void print_z(char *z, int len)
15 fprintf(stderr, "%c", z[i]);
16 fprintf(stderr, "\n");
19 unsigned char *jacu_mtf(unsigned char *datos, int len, unsigned char **_z, int *z_len)
25 pos = (unsigned char *)malloc(len*sizeof(unsigned char));
26 z = jacu_buscar_z(datos, len, &size);
27 *_z = (unsigned char*)malloc(len*sizeof(unsigned char));
28 memcpy(*_z, z, size*sizeof(unsigned char));
30 pos[i] = get_pos(z, size, datos[i]);
38 unsigned char *jacu_mtf_inv(unsigned char *z, unsigned char *pos, int len)
43 datos = (char*)malloc(sizeof(char)*len);
45 datos[i] = z[(unsigned int)pos[i]];
47 pop_front(z, (unsigned int)pos[i]);
52 unsigned char *jacu_buscar_z(unsigned char* datos, int len, int *size)
59 if( no_pertenece(z, datos[i], j) == -1 ){
61 z = realloc(z, j*sizeof(char));
70 int no_pertenece(char *z, char c, int len)
80 void pop_front(char *z, unsigned int pos)
85 if (pos > 255) printf("pos > = %u\n", pos);
86 if (pos < 0u) printf("pos < = %d\n", pos);
93 int get_pos(char *z, int len, char c)
96 if (z==NULL) return -1;
98 for(pos=0; pos<len; pos++)