X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/35fa025326ae9e6ab219b9016861dc1cedece945..77564f0b02a149dfb7e026768afe950d7e72a8e9:/otros/blocksorting/bs.c diff --git a/otros/blocksorting/bs.c b/otros/blocksorting/bs.c index 61dfb78..bf39971 100644 --- a/otros/blocksorting/bs.c +++ b/otros/blocksorting/bs.c @@ -1,22 +1,21 @@ +#include "bs.h" + /* Block Sorting Optimizado en memoria! */ -#include -#include -#include +typedef struct _bs_decode_t_ { + char c; + unsigned long int pos; +} t_BlockSortDecode; + +int _compare(const void *d1, const void *d2) { + t_BlockSortDecode *s1, *s2; -typedef struct _bs_data_t_ { - unsigned long int pos_inicial; - unsigned long int pos_final; - unsigned long int pos_orden; - char ord; /* indice si esta ordenada */ -} t_BlockSortData; + s1 = (t_BlockSortDecode *)d1; + s2 = (t_BlockSortDecode *)d2; -typedef struct _bs_t_ { - t_BlockSortData *array; - unsigned long int *ord; - unsigned long int len; -} t_BlockSort; + return (s1->c - s2->c); +} char es_menor(char *data, t_BlockSort *bs, int i, int j) { @@ -88,7 +87,30 @@ void bs_solve(char *in, char *out, t_BlockSort *bs, unsigned long int *k, unsign bs->len = l; } -t_BlockSort *bs_create(unsigned int len) +void bs_restore(char *dst, char *c, unsigned long int k, unsigned long int len) +{ + unsigned long int i, current; + t_BlockSortDecode *in; + + in = malloc(sizeof(t_BlockSortDecode)*len); + + for(i=0; i \n", argv[0]); - return 0; - } - - fp = fopen(argv[1], "r"); - len = atoi(argv[2]); - - data = malloc(sizeof(char)*len); - salida = malloc(sizeof(char)*len); - - bs = bs_create(len); - - while ((c = fgetc(fp)) != EOF) { - i = 0; - while ((c!=EOF) && (i < len)) { - data[i++] = c; - c = fgetc(fp); - } - bs_solve(data, salida, bs, &k, i); - - /* XXX ACA SALIDA DEBERIA PASAR A LA SIGUIENTE ETAPA XXX */ - } - fclose(fp); - bs_destroy(bs); - - free(data); - free(salida); - return 0; -} - -