public class FastIntSequenceSearch
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.
It also allows for case-insensitive search in integer indexables representing UTF-32 character codes,
as this is simple and fast to implement. Note that in this case the allowed character values in
the search term are checked to be in the Unicode range of 0x00 to 0x00_10_ff_ff.
The indexable in which the search term is searched is not checked for this restriction,
and there are no guarantees given to whatever happens in cases where it violates it.
| Modifier and Type | Field and Description |
|---|---|
static int |
UNICODE_MAX_VALUE
Maximum allowed character code value in the Unicode range.
|
| Constructor and Description |
|---|
FastIntSequenceSearch(boolean caseInsensitive,
int... searchTerm)
Convenience constructor.
|
FastIntSequenceSearch(int... searchTerm)
Convenience constructor.
|
FastIntSequenceSearch(IntIndexable searchTerm)
Constructor.
|
FastIntSequenceSearch(IntIndexable searchTerm,
boolean caseInsensitive)
Constructor.
|
FastIntSequenceSearch(java.lang.String searchTerm)
Convenience constructor.
|
FastIntSequenceSearch(java.lang.String searchTerm,
boolean caseInsensitive)
Convenience constructor.
|
| Modifier and Type | Method and Description |
|---|---|
IntIndexable |
findAllMatches(IntIndexable data,
boolean allowOverlaps)
Find all matches.
|
int |
findFirst(IntIndexable data)
Find the first appearance of the search term in the given data.
|
int |
findNext(IntIndexable data,
int pos)
Find the next appearance of the search term after the given position
in the given data.
|
int |
findNext(IntIndexable 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.
|
IntIndexable |
getSearchTerm()
Get the search term.
|
boolean |
isCaseInsensitive()
Is this search done case-insensitive?
|
public static final int UNICODE_MAX_VALUE
public FastIntSequenceSearch(@NotNull IntIndexable searchTerm)
searchTerm - term to search forpublic FastIntSequenceSearch(@NotNull IntIndexable searchTerm, boolean caseInsensitive)
searchTerm - term to search for (not empty)caseInsensitive - true: searching is done in a case-insensitive way (assuming UTF-32 encoding for all values)false: values have to match exactlypublic FastIntSequenceSearch(@NotNull java.lang.String searchTerm)
searchTerm - search termpublic FastIntSequenceSearch(@NotNull java.lang.String searchTerm, boolean caseInsensitive)
searchTerm - search termcaseInsensitive - true: searching is done in a case-insensitive way (assuming UTF-32 encoding for all values)false: values have to match exactlypublic FastIntSequenceSearch(@NotNull int... searchTerm)
searchTerm - search termpublic FastIntSequenceSearch(boolean caseInsensitive,
@NotNull
int... searchTerm)
caseInsensitive == true this will handle the values
as code points.searchTerm - search termcaseInsensitive - true: searching is done in a case-insensitive way (assuming UTF-32 encoding for all values)false: values have to match exactly@NotNull public IntIndexable getSearchTerm()
public boolean isCaseInsensitive()
true: if case is not cared forfalse: if values have to match exactlypublic int findFirst(@NotNull IntIndexable data)
data - data to search through-1 if there was nothing foundpublic int findNext(@NotNull IntIndexable 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 IntIndexable 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 IntIndexable data, boolean allowOverlaps)
data - data to searchallowOverlaps - allow overlapping sequences in the matches?