public class SearchTree<T> extends java.lang.Object implements ISearchTree<T>
Modifier and Type | Field and Description |
---|---|
protected SuffixArray<T> |
byId
A
SuffixArray that contains values keyed by the ID (as produced by idFunc ). |
protected SuffixArray<T> |
byName
A
SuffixArray that contains values keyed by the name (as produced by nameFunc ). |
Constructor and Description |
---|
SearchTree(java.util.function.Function<T,java.lang.Iterable<java.lang.String>> nameFuncIn,
java.util.function.Function<T,java.lang.Iterable<ResourceLocation>> idFuncIn) |
Modifier and Type | Method and Description |
---|---|
void |
add(T element)
Adds the given item to the search tree.
|
void |
recalculate()
|
java.util.List<T> |
search(java.lang.String searchText)
Searches this search tree for the given text.
|
protected SuffixArray<T> byId
SuffixArray
that contains values keyed by the ID (as produced by idFunc
).protected SuffixArray<T> byName
SuffixArray
that contains values keyed by the name (as produced by nameFunc
).public SearchTree(java.util.function.Function<T,java.lang.Iterable<java.lang.String>> nameFuncIn, java.util.function.Function<T,java.lang.Iterable<ResourceLocation>> idFuncIn)
public void recalculate()
public void add(T element)
element
- The element to addpublic java.util.List<T> search(java.lang.String searchText)
If the query does not contain a :
, then only byName
is searched; if it does contain a
colon, both byName
and byId
are searched and the results are merged using a MergingIterator
.
search
in interface ISearchTree<T>
searchText
- The text to search for. Must be normalized with toLowerCase(Locale.ROOT)
before
calling this method.