
var BWIndex = function(){
    this.txt = null;
    this.bwtarray = null;
    this.suffixarray = null;
    this.ranks = null;
    this.c = null;
    this.c_ord = null;
}

/**
 * Given a string, create and return an index object
 * @param {string} text This is the text to index
 * @return {object} This is an index object that can be used to
 *     search the text.
 */
function createBWIndex(text){
    var index = new BWIndex();

    index.txt = text;
    index.suffixarray = suffixArray(text);

    index.bwtarray = [];
    index.c = [];
    index.c_ord = {};
}

/**
 * Given an index object and search string, find all locations
 * where that string exists in the text.
 * @param {object} index This is an index object with the
 *     necessary information to quickly search the text
 * @param {string} str This is the string to search for in 
 *     the text
 * @return {array} This is an array of all locations that str
 *     appears in the text
 */
function findLocations(index, str){

}
@@ -487,24 +487,64 @@
 ray(text);%0A%0A
+    // Construct BWT array, C and C_ord%0A
     index.bw
@@ -596,16 +596,790 @@
 d = %7B%7D;%0A
+    for(var i=0; i %3C index.suffixarray.length; i++)%7B%0A%0A        // Construct BWT array%0A        if(index.suffixarray%5Bi%5D == 0)%7B%0A            index.bwtarray.push(index.suffixarray.length -1);%0A        %7D else %7B%0A            index.bwtarray.push(index.suffixarray%5Bi%5D - 1);%0A        %7D%0A%0A        // Construct C and C_ord%0A        var f_char = text.substr(index.suffixarray%5Bi%5D, %0A            index.suffixarray%5Bi%5D + 1);%0A%0A        // Add to C if there is nothing in it, or%0A        // if we have reached a new first character in the%0A        // suffix array.%0A        if(index.c.length == 0 %7C%7C%0A            text.substr(index.suffixarray%5Bi-1%5D, %0A                index.suffixarray%5Bi-1%5D+1) != f_char)%7B%0A            index.c.push(i);%0A            index.c_ord%5B'f_char'%5D = index.c.length - 1;%0A        %7D%0A    %7D%0A
 %7D%0A%0A/**%0A 

Add suffixarray, bwt and C creation to createBWIndex function