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(size*sizeof(unsigned char));
28 memcpy(*_z, z, size*sizeof(unsigned char));
30 pos[i] = get_pos(z, size, datos[i]);
39 unsigned char *jacu_mtf_inv(unsigned char *z, unsigned char *pos, int len)
44 datos = (char*)malloc(sizeof(char)*len);
46 datos[i] = z[(unsigned int)pos[i]];
48 pop_front(z, (unsigned int)pos[i]);
53 unsigned char *jacu_buscar_z(unsigned char* datos, int len, int *size)
60 if( no_pertenece(z, datos[i], j) == -1 ){
62 z = realloc(z, j*sizeof(char));
71 int no_pertenece(char *z, char c, int len)
81 void pop_front(char *z, unsigned int pos)
86 if (pos > 255) printf("pos > = %u\n", pos);
87 if (pos < 0u) printf("pos < = %d\n", pos);
94 int get_pos(char *z, int len, char c)
97 if (z==NULL) return -1;
99 for(pos=0; pos<len; pos++)