X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/551c1b8346a4c4a5128a7cfe4d4804bf40b4a0d2..2e29fc7e9a20173cb2e58bb93a72bca5e57a912d:/src/blocksorting/bs.c diff --git a/src/blocksorting/bs.c b/src/blocksorting/bs.c index 0aff024..d8bd093 100644 --- a/src/blocksorting/bs.c +++ b/src/blocksorting/bs.c @@ -6,7 +6,7 @@ typedef struct _bs_decode_t_ { char c; - Uint32 pos; + Uint32 sig; } t_BlockSortDecode; char es_menor(char *data, t_BlockSort *bs, int i, int j); @@ -17,16 +17,28 @@ int _compare(const void *d1, const void *d2) { s1 = (t_BlockSortDecode *)d1; s2 = (t_BlockSortDecode *)d2; + /* Hack si es el mismo caracter, dejo como mejor la de menor sig */ + if (s1->c == s2->c) { + return (s1->sig - s2->sig); + } + return (s1->c - s2->c); } int __compare(const void *d1, const void *d2) { t_BlockSortData *s1, *s2; + char i; s1 = (t_BlockSortData *)d1; s2 = (t_BlockSortData *)d2; - return es_menor(s1->bs->data, s1->bs, s1->pos_inicial, s2->pos_inicial); + i = es_menor(s1->bs->data, s1->bs, s1->pos_inicial, s2->pos_inicial); + +/* if (i == 0) {*/ + /* si ambos strings son iguales, fuerzo a que d1 quede primero */ + /*return -1; + }*/ + return i; } char es_menor(char *data, t_BlockSort *bs, int i, int j) @@ -42,6 +54,7 @@ char es_menor(char *data, t_BlockSort *bs, int i, int j) } /* Son iguales! */ + /* Hack */ return 0; } @@ -66,8 +79,8 @@ void print_(char *data, Uint32 pos, Uint32 len) Uint32 i; for(i=0; i %ld\n", *k, *(Uint32 *)(out+sizeof(Uint32))); bs->len = l; } @@ -115,7 +127,7 @@ void bs_restore(char *dst, char *c, Uint32 k, Uint32 len) for(i=0; i