public class FastByteSequenceSearch
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.
Constructor and Description |
---|
FastByteSequenceSearch(byte... searchTerm)
Constructor.
|
FastByteSequenceSearch(ByteIndexable searchTerm)
Constructor.
|
FastByteSequenceSearch(int... searchTerm)
Convenience constructor.
|
Modifier and Type | Method and Description |
---|---|
IntIndexable |
findAllMatches(ByteIndexable data,
boolean allowOverlaps)
Find all matches.
|
int |
findFirst(ByteIndexable data)
Find the first appearance of the search term in the given data.
|
int |
findNext(ByteIndexable data,
int pos)
Find the next appearance of the search term after the given position
in the given data.
|
int |
findNext(ByteIndexable 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.
|
ByteIndexable |
getSearchTerm()
Get the search term.
|
public FastByteSequenceSearch(@NotNull ByteIndexable searchTerm)
searchTerm
- term to search forpublic FastByteSequenceSearch(byte... searchTerm)
searchTerm
- bytes to search forpublic FastByteSequenceSearch(int... searchTerm)
searchTerm
- bytes to search for,@NotNull public ByteIndexable getSearchTerm()
public int findFirst(@NotNull ByteIndexable data)
data
- data to search through-1
if there was nothing foundpublic int findNext(@NotNull ByteIndexable 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 ByteIndexable 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 ByteIndexable data, boolean allowOverlaps)
data
- data to searchallowOverlaps
- allow overlapping sequences in the matches?