public class FastCharSequenceSearch
extends java.lang.Object
Currently only forward search is implemented, but basically both the search indexable
and the searched indexable can be reversed before searching.
Although based on integers this may also be used for searches in byte or character sequences.
It also allows for case-insensitive search in character indexables, as this is simple and fast to implement.
| Constructor and Description |
|---|
FastCharSequenceSearch(boolean caseInsensitive,
char... searchTerm)
Convenience constructor.
|
FastCharSequenceSearch(char... searchTerm)
Convenience constructor.
|
FastCharSequenceSearch(CharIndexable searchTerm)
Constructor.
|
FastCharSequenceSearch(CharIndexable searchTerm,
boolean caseInsensitive)
Constructor.
|
FastCharSequenceSearch(java.lang.String searchTerm)
Convenience constructor.
|
FastCharSequenceSearch(java.lang.String searchTerm,
boolean caseInsensitive)
Convenience constructor.
|
| Modifier and Type | Method and Description |
|---|---|
IntIndexable |
findAllMatches(CharIndexable data,
boolean allowOverlaps)
Find all matches.
|
int |
findFirst(CharIndexable data)
Find the first appearance of the search term in the given data.
|
int |
findNext(CharIndexable data,
int pos)
Find the next appearance of the search term after the given position
in the given data.
|
int |
findNext(CharIndexable data,
int pos,
int end)
Find the next appearance of the search term after the given start position
and before the given end position in the given data.
|
CharIndexable |
getSearchTerm()
Get the search term.
|
boolean |
isCaseInsensitive()
Is this search done case-insensitive?
|
public FastCharSequenceSearch(@NotNull CharIndexable searchTerm)
searchTerm - term to search forpublic FastCharSequenceSearch(@NotNull CharIndexable searchTerm, boolean caseInsensitive)
searchTerm - term to search forcaseInsensitive - true: searching is done in a case-insensitive way (assuming UTF-16 encoding for all character values)false: characters have to match exactlypublic FastCharSequenceSearch(@NotNull java.lang.String searchTerm)
searchTerm - search termpublic FastCharSequenceSearch(@NotNull java.lang.String searchTerm, boolean caseInsensitive)
searchTerm - search termcaseInsensitive - true: searching is done in a case-insensitive way (assuming UTF-16 encoding for all character values)false: characters have to match exactlypublic FastCharSequenceSearch(@NotNull char... searchTerm)
searchTerm - search termpublic FastCharSequenceSearch(boolean caseInsensitive,
@NotNull
char... searchTerm)
searchTerm - search termcaseInsensitive - true: searching is done in a case-insensitive way (assuming UTF-16 encoding for all character values)false: characters have to match exactly@NotNull public CharIndexable getSearchTerm()
public boolean isCaseInsensitive()
true: if case is not cared forfalse: if characters have to match exactlypublic int findFirst(@NotNull CharIndexable data)
data - data to search through-1 if there was nothing foundpublic int findNext(@NotNull CharIndexable data, int pos)
data - data to search throughpos - position to start the search-1 if there was nothing found between the position and the end of datapublic int findNext(@NotNull CharIndexable data, int pos, int end)
data - data to search throughpos - position to start the searchend - position to end the search, the whole search term has to fit before this position to be found-1 if there was nothing found between the position and the end of data@NotNull public IntIndexable findAllMatches(@NotNull CharIndexable data, boolean allowOverlaps)
data - data to searchallowOverlaps - allow overlapping sequences in the matches?