如何搜索基于charAt的数组

我无法理解正在实现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吗?

gjuny 回答:如何搜索基于charAt的数组

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3128624.html

大家都在问