@Environment(value=CLIENT) public class SuffixArray<T> extends Object
Modifier and Type | Field and Description |
---|---|
private it.unimi.dsi.fastutil.ints.IntList |
characters |
private static Logger |
LOGGER |
private int |
maxTextLength |
protected List<T> |
objects |
private it.unimi.dsi.fastutil.ints.IntList |
offsetInText |
private static boolean |
PRINT_ARRAY |
private static boolean |
PRINT_COMPARISONS |
private it.unimi.dsi.fastutil.ints.IntList |
suffixIndexToObjectIndex |
private it.unimi.dsi.fastutil.ints.IntList |
textStarts |
Constructor and Description |
---|
SuffixArray() |
Modifier and Type | Method and Description |
---|---|
void |
add(T object,
String text)
Adds a text with the corresponding object.
|
void |
build()
Builds a suffix array with added texts.
|
private int |
compare(String string,
int suffixIndex) |
List<T> |
findAll(String text)
Retrieves all objects of which corresponding texts contain
text . |
private String |
getDebugString(int suffixIndex) |
private void |
printArray() |
private static final boolean PRINT_COMPARISONS
private static final boolean PRINT_ARRAY
private static final Logger LOGGER
private final it.unimi.dsi.fastutil.ints.IntList characters
private final it.unimi.dsi.fastutil.ints.IntList textStarts
private it.unimi.dsi.fastutil.ints.IntList suffixIndexToObjectIndex
private it.unimi.dsi.fastutil.ints.IntList offsetInText
private int maxTextLength
public void add(T object, String text)
You are not allowed to call this method after calling build()
method.
Takes O(text.length()
) time.
public void build()
You are not allowed to call this method multiple times.
Takes O(N * log N * log M) time on average where N is the sum of all text length added, and M is the maximum text length added.
private void printArray()
private String getDebugString(int suffixIndex)
private int compare(String string, int suffixIndex)
public List<T> findAll(String text)
text
.
You have to call build()
method before calling this method.
Takes O(text.length()
* log N) time to find objects where N is the
sum of all text length added. Takes O(X + Y * log Y) time to collect found
objects into a list where X is the number of occurrences of text
in all
texts added, and Y is the number of found objects.