public class KnuthMorrisPrattAlgorithm extends Object
| Constructor and Description |
|---|
KnuthMorrisPrattAlgorithm(String needle)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
execute(String haystack)
Execute the search algorithm.
|
int |
execute(String haystack,
int index)
Execute the search algorithm.
|
public KnuthMorrisPrattAlgorithm(String needle)
needle - the search string for which the instance will be constructed.public int execute(String haystack)
haystack - the string in which to search for the needle specified at
construction time.public int execute(String haystack, int index)
haystack - the string in which to search for the needle specified at
construction time.index - the index at which to begin the search within the haystack
string.Copyright © 1994–2024 Peter Murray-Rust. All rights reserved.