naivestringmatcher.java

来自「java版的数据结构的完全代码 免费提供了 学习数据结构的请下载」· Java 代码 · 共 22 行

JAVA
22
字号
// Introduced in Chapter 13/** Simply checks each position in the text for the pattern. */public class NaiveStringMatcher extends AbstractStringMatcher {  /** Pattern is the pattern being sought. */  public NaiveStringMatcher(String pattern) {    super(pattern);  }  public int match(String text) {    for (int position = 0;         position + getPattern().length() <= text.length();         position++) {      if (matchAt(text, position)) {        return position;      }    }    return -1;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?