typedef struct _bs_decode_t_ {
char c;
- unsigned long int pos;
+ Uint32 pos;
} t_BlockSortDecode;
char es_menor(char *data, t_BlockSort *bs, int i, int j);
char es_menor(char *data, t_BlockSort *bs, int i, int j)
{
- unsigned long int pi, pj, k;
+ Uint32 pi, pj, k;
for(k=0; k<bs->len; k++) {
pi = (i+k)%bs->len;
qsort(bs->array, bs->len, sizeof(t_BlockSortData), __compare);
}
-void print_(char *data, unsigned long int pos, unsigned long int len)
+void print_(char *data, Uint32 pos, Uint32 len)
{
- unsigned long int i;
+ Uint32 i;
for(i=0; i<len; i++)
printf("%c", data[(pos+i)%len]);
int generar_salida(char *data, t_BlockSort *bs, char *salida)
{
- unsigned long int i, k;
+ Uint32 i, k;
char *out;
/* Dejo lugar para guardar el k y el tamaño de este bloque */
- out = salida + sizeof(unsigned long int)*2;
+ out = salida + sizeof(Uint32)*2;
k=-1;
for(i=0; i<bs->len; i++) {
return k;
}
-void bs_solve(char *in, char *out, t_BlockSort *bs, unsigned long int *k, unsigned int leido)
+void bs_solve(char *in, char *out, t_BlockSort *bs, Uint32 *k, Uint32 leido)
{
unsigned int l;
l = bs->len;
(*k) = generar_salida(in, bs, out);
/* Guardo el k y el tamaño en el array */
- memcpy(out, &leido, sizeof(unsigned long int));
- memcpy(out+sizeof(unsigned long int), k, sizeof(unsigned long int));
-
+ memcpy(out, &leido, sizeof(Uint32));
+ memcpy(out+sizeof(Uint32), k, sizeof(Uint32));
+ printf("%ld -> %ld\n", *k, *(Uint32 *)(out+sizeof(Uint32)));
bs->len = l;
}
-void bs_restore(char *dst, char *c, unsigned long int k, unsigned long int len)
+void bs_restore(char *dst, char *c, Uint32 k, Uint32 len)
{
- unsigned long int i, current;
+ Uint32 i, current;
t_BlockSortDecode *in;
in = malloc(sizeof(t_BlockSortDecode)*len);
i=0;
do {
dst[i++] = in[current].c;
+ printf("(%c)", dst[i-1]);
current = in[current].pos;
+ printf("[%d]", current);
} while (current != k);
+ printf("\n");
free(in);
}
-t_BlockSort *bs_create(unsigned long int len)
+t_BlockSort *bs_create(Uint32 len)
{
t_BlockSort *tmp;