/*
 * call-seq:
 *   sarray.all_starts(character) -> Array
 *
 * Returns an array containing all the indexes into the source that start
 * with the given character.  This is a very fast operation since the 
 * SuffixArray already knows where each character starts and ends in the
 * suffix array structure internally.  All it does is copy the range of
 * the suffix array for that region.
 */
static VALUE SuffixArray_all_starts(VALUE self, VALUE character)
{
    SuffixArray *sa = NULL;
    Data_Get_Struct(self, SuffixArray, sa);
    
    VALUE result = rb_ary_new();
    VALUE char_str = StringValue(character);
    
    // must be at least one length
    if(RSTRING(char_str)->len > 0) {
        char ch = RSTRING(char_str)->ptr[0];

        // go through all the suffix array indices as indicated by sa->starts and sa->ends
        size_t start = 0;
    
        for(start = sa->starts[ch]; start <= sa->ends[ch]; start++) {
            rb_ary_push(result, INT2FIX(sa->suffix_index[start]));
        }
    }
    
    return result;
}