我无法理解正在实现KMP文本搜索算法的代码。
这是解决我问题的完整方法
private final int[][] nextCheck;
protected final String defaultTarget;
public TextSearchKMP(String target){
nextCheck = new int[65_536][target.length];
nextCheck[target.charAt(0)][0] = 1;
for (int x = 0; j = 1; j < target.length(); j++){
assert x < j;
for (int c = 0; c < nextCheck.length; c++){
nextCheck[c][j] = nextCheck[c][x];
}
nextCheck[target.charAt(j)][j] = j +1 ;
x = nextCheck[target.charAt(j)][x]
}
}
这是我无法理解的那一行。
nextCheck[target.charAt(j)][j] = j +1
如何通过charAt搜索数组? charAt返回一个字符,就我而言,您搜索数组时使用int吗?