优艾设计网

if里面为何不直接使用continue??

优艾设计网 https://www.uibq.com 2023-06-01 07:50 出处:网络 作者:PS百科
static int indexOf(char[] source, int sourceOffset, int sourceCount, char[] target, int targetOffset, int targetCount, int fromIndex) { if (fromIndex >= sourceCount) { return (targetC优艾设计网_设计

static int indexOf(char[] source, int sourceOffset, int sourceCount, char[] target, int targetOffset, int targetCount, int fromIndex) { if (fromIndex >= sourceCount) { return (targetC优艾设计网_设计客ount == 0 ? sourceCount : -1); } if (fromIndex < 0) { fromIndex = 0; } if (targetCount == 0) { return fromIndex; }char first = target[targetOffset]; int max = sourceOffset + (sourceCount - targetCount);for (int i = sourceOffset + fromIndex; i <= max; i++) { /* Look for first character. */ if (source[i] != first) { while (++i <= max && source[i] != first); }/* Found first character, now look at the rest of v2 */ if (i <= max) { int j = i + 1; int end = j + targetCount - 1; for (int k = targetOffset + 1; j < end && source[j] == target[k]; j++, k++);if (j == end) { /* Found whole string. */ return i - sourceOffset; } } } return -1; }

if里面为何不直接使用continue?


0

精彩评论

暂无评论...
验证码 换一张
取 消