Package net.minecraft.client.search
Class SuffixArray<T>
java.lang.Object
net.minecraft.client.search.SuffixArray<T>
@Environment(CLIENT) public class SuffixArray<T> extends Object
Provides an efficient way to search for a text in multiple texts.
-
Field Summary
Fields Modifier and Type Field Description private IntListcharactersprivate static LoggerLOGGERprivate intmaxTextLengthprotected List<T>objectsprivate IntListoffsetInTextprivate static booleanPRINT_ARRAYprivate static booleanPRINT_COMPARISONSprivate IntListsuffixIndexToObjectIndexprivate IntListtextStarts -
Constructor Summary
Constructors Constructor Description SuffixArray() -
Method Summary
Modifier and Type Method Description voidadd(T object, String text)Adds a text with the corresponding object.voidbuild()Builds a suffix array with added texts.private intcompare(String string, int suffixIndex)List<T>findAll(String text)Retrieves all objects of which corresponding texts containtext.private StringgetDebugString(int suffixIndex)private voidprintArray()
-
Field Details
-
PRINT_COMPARISONS
private static final boolean PRINT_COMPARISONS -
PRINT_ARRAY
private static final boolean PRINT_ARRAY -
LOGGER
-
objects
-
characters
-
textStarts
-
suffixIndexToObjectIndex
-
offsetInText
-
maxTextLength
private int maxTextLength
-
-
Constructor Details
-
SuffixArray
public SuffixArray()
-
-
Method Details
-
add
Adds a text with the corresponding object.You are not allowed to call this method after calling
build()method.Takes O(
text.length()) time. -
build
public void build()Builds a suffix array with added texts.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.
-
printArray
private void printArray() -
getDebugString
-
compare
-
findAll
Retrieves all objects of which corresponding texts containtext.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 oftextin all texts added, and Y is the number of found objects.
-