lib/BWT.js
function(T, SA, C, B, n, k) {
        var b, i, j;
        var c0, c1;
        /* compute SAl */
        if (C === B) { getCounts(T, C, n, k); }
        getBuckets(C, B, k, false); /* find starts of buckets */
        j = n - 1;
        b = B[c1 = T[j]];
        j--;
        SA[b++] = (T[j] < c1) ? ~j : j;
        for (i = 0; i < n; i++) {
            if ((j = SA[i]) > 0) {
                ASSERT(T[j] >= T[j+1]);
                if ((c0 = T[j]) !== c1) { B[c1] = b; b = B[c1 = c0]; }
                ASSERT(i < b);
                j--;
                SA[b++] = (T[j] < c1) ? ~j : j;
                SA[i] = 0;
            } else if (j < 0) {
                SA[i] = ~j;
            }
        }
        /* compute SAs */
        if (C === B) { getCounts(T, C, n, k); }
        getBuckets(C, B, k, 1); /* find ends of buckets */
        for (i = n-1, b = B[c1 = 0]; i >= 0; i--) {
            if ((j = SA[i]) > 0) {
                ASSERT(T[j] <= T[j+1]);
                if ((c0 = T[j]) !== c1) { B[c1] = b; b = B[c1 = c0]; }
                ASSERT(b <= i);
                j--;
                SA[--b] = (T[j] > c1) ? ~(j+1) : j;
                SA[i] = 0;
            }
        }
    }
function(T, SA, C, B, n, k) {
        var b, i, j;
        var c0, c1;
        /* compute SAl */
        if (C === B) { getCounts(T, C, n, k); }
        getBuckets(C, B, k, false); /* find starts of buckets */
        j = n - 1;
        b = B[c1 = T[j]];
        j--;
        SA[b++] = (T[j] < c1) ? ~j : j;
        for (i = 0; i < n; i++) {
            if ((j = SA[i]) > 0) {
                ASSERT(T[j] >= T[j+1]);
                if ((c0 = T[j]) !== c1) { B[c1] = b; b = B[c1 = c0]; }
                ASSERT(i < b);
                j--;
                SA[b++] = (T[j] < c1) ? ~j : j;
                SA[i] = 0;
            } else if (j < 0) {
                SA[i] = ~j;
            }
        }
        /* compute SAs */
        if (C === B) { getCounts(T, C, n, k); }
        getBuckets(C, B, k, 1); /* find ends of buckets */
        for (i = n-1, b = B[c1 = 0]; i >= 0; i--) {
            if ((j = SA[i]) > 0) {
                ASSERT(T[j] <= T[j+1]);
                if ((c0 = T[j]) !== c1) { B[c1] = b; b = B[c1 = c0]; }
                ASSERT(b <= i);
                j--;
                SA[--b] = (T[j] > c1) ? ~(j+1) : j;
                SA[i] = 0;
            }
        }
    }
function ( T , SA , C , B , n , k ) { var b , i , j ; var c0 , c1 ; /* compute SAl */ if ( C === B ) { getCounts ( T , C , n , k ) ; } getBuckets ( C , B , k , false ) ; /* find starts of buckets */ j = n - 1 ; b = B [ c1 = T [ j ] ] ; j -- ; SA [ b ++ ] = ( T [ j ] < c1 ) ? ~ j : j ; for ( i = 0 ; i < n ; i ++ ) { if ( ( j = SA [ i ] ) > 0 ) { ASSERT ( T [ j ] >= T [ j + 1 ] ) ; if ( ( c0 = T [ j ] ) !== c1 ) { B [ c1 ] = b ; b = B [ c1 = c0 ] ; } ASSERT ( i < b ) ; j -- ; SA [ b ++ ] = ( T [ j ] < c1 ) ? ~ j : j ; SA [ i ] = 0 ; } else if ( j < 0 ) { SA [ i ] = ~ j ; } } /* compute SAs */ if ( C === B ) { getCounts ( T , C , n , k ) ; } getBuckets ( C , B , k , 1 ) ; /* find ends of buckets */ for ( i = n - 1 , b = B [ c1 = 0 ] ; i >= 0 ; i -- ) { if ( ( j = SA [ i ] ) > 0 ) { ASSERT ( T [ j ] <= T [ j + 1 ] ) ; if ( ( c0 = T [ j ] ) !== c1 ) { B [ c1 ] = b ; b = B [ c1 = c0 ] ; } ASSERT ( b <= i ) ; j -- ; SA [ -- b ] = ( T [ j ] > c1 ) ? ~ ( j + 1 ) : j ; SA [ i ] = 0 ; } } }
Sort all type LMS suffixes
Sort all type LMS suffixes