Class PermutermTrie<E>
java.lang.Object
java.util.AbstractMap<K,V>
org.apache.commons.collections4.trie.AbstractBitwiseTrie<K,V>
org.apache.commons.collections4.trie.PatriciaTrie<E>
io.github.douira.glsl_transformer.ast.query.DuplicatorTrie<E>
io.github.douira.glsl_transformer.ast.query.PermutermTrie<E>
- All Implemented Interfaces:
Serializable,Map<String,,E> SortedMap<String,,E> Get<String,,E> IterableGet<String,,E> IterableMap<String,,E> IterableSortedMap<String,,E> OrderedMap<String,,E> Put<String,,E> Trie<String,E>
This permuterm trie supports prefix, suffix, infix and inverted infix (suffix
+ prefix) queries and works by inserting all rotations of the key into the
underlying trie. The number of bits used to index an entry is quadratic in
the size of the key.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.github.douira.glsl_transformer.ast.query.DuplicatorTrie
DuplicatorTrie.Holder<V>Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
FieldsFields inherited from class io.github.douira.glsl_transformer.ast.query.DuplicatorTrie
DEFAULT_MARKER, marker -
Constructor Summary
ConstructorsConstructorDescriptionPermutermTrie(char marker) PermutermTrie(Map<? extends String, ? extends E> m) PermutermTrie(Map<? extends String, ? extends E> m, char marker) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Comparator<? super String>entrySet()firstKey()Gets the first key currently in this map.infixQuery(String infix) Returns a stream of all the elements that have a given infix (substring).protected voiditerateKeyVariations(String key, Consumer<String> consumer) keySet()lastKey()Gets the last key currently in this map.Obtains anOrderedMapIteratorover the map.prefixQuery(String prefix) Returns a stream of all the elements that have a given prefix.protected StringprepareKey(Object k) selectValue(String key) Returns the value whose key is closest in a bitwise XOR metric to the provided key.intsize()suffixPrefixQuery(String prefix, String suffix) Returns a stream of all the elements that have a given prefix and suffix.suffixQuery(String suffix) Returns a stream of all the elements that have a given suffix.values()Methods inherited from class io.github.douira.glsl_transformer.ast.query.DuplicatorTrie
containsKey, distinctPrefixQuery, get, headMap, nextKey, prefixMap, prefixMapRaw, previousKey, put, remove, sanitizeKey, select, selectKey, subMap, tailMapMethods inherited from class org.apache.commons.collections4.trie.AbstractBitwiseTrie
getKeyAnalyzer, toStringMethods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, putAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.collections4.Get
containsValue, isEmptyMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsValue, equals, forEach, getOrDefault, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
modCount
protected transient int modCount
-
-
Constructor Details
-
PermutermTrie
public PermutermTrie() -
PermutermTrie
-
PermutermTrie
public PermutermTrie(char marker) -
PermutermTrie
-
-
Method Details
-
iterateKeyVariations
- Specified by:
iterateKeyVariationsin classDuplicatorTrie<E>
-
prepareKey
- Overrides:
prepareKeyin classDuplicatorTrie<E>
-
prefixQuery
Returns a stream of all the elements that have a given prefix.- Parameters:
prefix- the prefix to search for- Returns:
- the elements that have the prefix
-
suffixQuery
Returns a stream of all the elements that have a given suffix.- Parameters:
suffix- the suffix to search for- Returns:
- the elements that have the suffix
-
infixQuery
Returns a stream of all the elements that have a given infix (substring).- Parameters:
infix- the infix to search for- Returns:
- the elements that have the infix
-
suffixPrefixQuery
Returns a stream of all the elements that have a given prefix and suffix.- Parameters:
prefix- the prefix to search requiresuffix- the suffix to search require- Returns:
- the elements that have the prefix and suffix
-
clear
public void clear() -
size
public int size() -
selectValue
Returns the value whose key is closest in a bitwise XOR metric to the provided key. This is NOT lexicographic closeness! For example, given the keys:- D = 1000100
- H = 1001000
- L = 1001100
Triecontained 'H' and 'L', a lookup of 'D' would return 'L', because the XOR distance between D & L is smaller than the XOR distance between D & H.- Parameters:
key- the key to use in the search- Returns:
- the value whose key is closest in a bitwise XOR metric to the provided key
-
entrySet
-
keySet
-
values
-
comparator
-
firstKey
Description copied from interface:OrderedMapGets the first key currently in this map.- Returns:
- the first key currently in this map
-
lastKey
Description copied from interface:OrderedMapGets the last key currently in this map.- Returns:
- the last key currently in this map
-
mapIterator
Description copied from interface:OrderedMapObtains anOrderedMapIteratorover the map.A ordered map iterator is an efficient way of iterating over maps in both directions.
- Returns:
- a map iterator
-