private static int compare(final char[] cer, final String text, final int start, final int end) {
        final int textLen = end - start;
        final int maxCommon = Math.min(cer.length, textLen);
        int i;
        // char 0 is discarded, will be & in both cases
        for (i = 1; i < maxCommon; i++) {
            final char tc = text.charAt(start + i);
            if (cer[i] < tc) {
                return -1;
            } else if (cer[i] > tc) {
                return 1;
            }
        }
        if (cer.length > i) {
            return 1;
        }
        if (textLen > i) {
            return -1;
        }
        return 0;
    }
private static int compare ( final char [ ] cer , final String text , final int start , final int end ) { final int textLen = end - start ; final int maxCommon = Math . min ( cer . length , textLen ) ; int i ; for ( i = 1 ; i < maxCommon ; i ++ ) { final char tc = text . charAt ( start + i ) ; if ( cer [ i ] < tc ) { return - 1 ; } else if ( cer [ i ] > tc ) { return 1 ; } } if ( cer . length > i ) { return 1 ; } if ( textLen > i ) { return - 1 ; } return 0 ; }
/*
These two methods (two versions: for String and for char[]) compare each of the candidate
text fragments with an CER coming from the SORTED_CERS array, during binary search operations.