X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=results.c;h=7570e5ab3c38bbd3ee1f481a9f2d7f348f796524;hb=cf6d366b25132eea7b0f1966c11d034d748af0fa;hp=161f2956bf86ee75cc027f148717156fc30db21a;hpb=329088598ab63bc2d67ff0dfc4f54e90f5d4f283;p=SXSI%2Fxpathcomp.git diff --git a/results.c b/results.c index 161f295..7570e5a 100644 --- a/results.c +++ b/results.c @@ -26,8 +26,11 @@ results createResults (int n) { fprintf(stderr,"Error, redefine logW as %i and recompile\n",lg(W)-1); exit(1); } + R.n = 2*n-1; R.lgn = lg(n); + fprintf(stderr,"Size of the result set : %i elements, %li kB\n", n, + (((R.n+W-1)/W)*sizeof(int)/1024)); R.tree = (int*) malloc (((R.n+W-1)/W)*sizeof(int)); clearBit(R.tree,0); // clear all return R; @@ -206,6 +209,20 @@ int nextResult (results R, int p) // returns pos of next(p) or -1 if none return unconv(answ,R.n,R.lgn); } +// Naively implemented by kim + +unsigned int countResult(results R) { + unsigned int result = 0; + int i = 0; + while ( i != -1 && i < R.n) { + result ++; + i = unconv(nextLarger(R.tree,R.n,conv(i+1,R.n,R.lgn),0,R.lgn),R.n,R.lgn); + }; + return result; + +} + + static void prnspace (int k) { while (k--) putchar(' ');