Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/martin/Documents/svnrepo/trunk/martin/compsci@762 3ab4d77f-209f-454f-af32-ffe4b78d429c
  • Loading branch information
ept committed May 27, 2005
1 parent e42567b commit 909e056
Show file tree
Hide file tree
Showing 5 changed files with 2,082 additions and 4 deletions.
8 changes: 7 additions & 1 deletion burrowswheeler/Makefile
@@ -1,4 +1,4 @@
all: bw bw-i
all: bw bw-i mtf mtf-i

clean:
rm -f *.o bw bw-i
Expand All @@ -9,3 +9,9 @@ bw: bw.o
bw-i: bw-i.o
gcc -o $@ $<

mtf: mtf.o
gcc -o $@ $<

mtf-i: mtf-i.o
gcc -o $@ $<

6 changes: 3 additions & 3 deletions burrowswheeler/bw-i.c
Expand Up @@ -4,7 +4,7 @@

unsigned char L[BLOCKSIZE], F[BLOCKSIZE], S[BLOCKSIZE];
int T[BLOCKSIZE];
char buf[2];
unsigned char buf[2];
int I;


Expand Down Expand Up @@ -34,9 +34,9 @@ int main() {
int n, block=1;
while (1) {
if (fread(buf, 1, 2, stdin) < 2) break;
I = buf[0] | (buf[1] << 8);
I = buf[0] + 256*buf[1];
if (fread(L, 1, BLOCKSIZE, stdin) < BLOCKSIZE) break;
fprintf(stderr, "Block %d\n", block);
fprintf(stderr, "Block %d\n", block, I);
memcpy(F, L, BLOCKSIZE);
qsort(F, BLOCKSIZE, 1, cmp_char);
calcT();
Expand Down
24 changes: 24 additions & 0 deletions burrowswheeler/mtf-i.c
@@ -0,0 +1,24 @@
#include <stdio.h>

#define BUFSIZE 256

unsigned char inbuf[BUFSIZE], outbuf[BUFSIZE], map[256], ch;
int size;

int main() {
int i, j;
for (i=0; i<256; i++) map[i] = i;
while (size = fread(inbuf, 1, BUFSIZE, stdin)) {
for (i=0; i<size; i++) {
j = inbuf[i];
ch = map[j];
outbuf[i] = ch;
while (j > 0) {
map[j] = map[j-1]; j--;
}
map[0] = ch;
}
fwrite(outbuf, 1, size, stdout);
}
return 0;
}
25 changes: 25 additions & 0 deletions burrowswheeler/mtf.c
@@ -0,0 +1,25 @@
#include <stdio.h>

#define BUFSIZE 256

unsigned char inbuf[BUFSIZE], outbuf[BUFSIZE], map[256], ch;
int size;

int main() {
int i, j;
for (i=0; i<256; i++) map[i] = i;
while (size = fread(inbuf, 1, BUFSIZE, stdin)) {
for (i=0; i<size; i++) {
ch = inbuf[i];
j = 0;
while (map[j] != ch) j++;
outbuf[i] = j;
while (j > 0) {
map[j] = map[j-1]; j--;
}
map[0] = ch;
}
fwrite(outbuf, 1, size, stdout);
}
return 0;
}

0 comments on commit 909e056

Please sign in to comment.