fprintf(stderr, "\n");
}
-int *jacu_mtf(char *datos, int len)
+char *jacu_mtf(char *datos, int len, char **_z, int *z_len)
{
char *z;
- int *pos;
+ char *pos;
int i, size;
- pos = (int*)malloc(len*sizeof(int));
+ pos = (char *)malloc(len*sizeof(char));
z = jacu_buscar_z(datos, len, &size);
+ (*_z) = jacu_buscar_z(datos, len, &size);
+
for(i=0; i<len; i++){
pos[i] = get_pos(z, size, datos[i]);
+ printf("pos de %c = %d\n", datos[i], pos[i]);
if (pos[i] != 0)
- pop_front(z,pos[i]);
+ pop_front(z, pos[i]);
}
+
+ /*(*_z) = z;*/
+ (*z_len) = size;
return pos;
}
+char *jacu_mtf_inv(char *z, char *pos, int len)
+{
+ char *datos;
+ int i;
+
+ datos = (char*)malloc(sizeof(char)*len);
+ for(i=0; i<len; i++){
+ datos[i] = z[(size_t)pos[i]];
+ pop_front(z, pos[i]);
+ }
+ return datos;
+}
char *jacu_buscar_z(char* datos, int len, int *size)
{