Class PrefixSuffixTrie<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<Set<E>>
io.github.douira.glsl_transformer.ast.query.PrefixSuffixTrie<E>
- All Implemented Interfaces:
PrefixQueryable<E>,SuffixQueryable<E>,Serializable,Map<String,,Set<E>> SortedMap<String,,Set<E>> Get<String,,Set<E>> IterableGet<String,,Set<E>> IterableMap<String,,Set<E>> IterableSortedMap<String,,Set<E>> OrderedMap<String,,Set<E>> Put<String,,Set<E>> Trie<String,Set<E>>
public class PrefixSuffixTrie<E>
extends DuplicatorTrie<Set<E>>
implements PrefixQueryable<E>, SuffixQueryable<E>
This prefix-suffix trie supports both prefix and suffix queries but no
infix-related queries and works by inserting the key and its reverse into the
underlying trie. This is more efficient than the permuterm trie since the
number of bits used to index an entry is not quadratic in the size of the key
but linear.
- 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
ConstructorsConstructorDescriptionPrefixSuffixTrie(char marker) PrefixSuffixTrie(Map<? extends String, ? extends Set<E>> m) PrefixSuffixTrie(Map<? extends String, ? extends Set<E>> m, char marker) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Comparator<? super String>entrySet()firstKey()Gets the first key currently in this map.protected voiditerateKeyVariations(String key, Consumer<String> consumer) keySet()lastKey()Gets the last key currently in this map.Obtains anOrderedMapIteratorover the map.prefixQuery(String prefix) selectValue(String key) Returns the value whose key is closest in a bitwise XOR metric to the provided key.intsize()suffixQuery(String suffix) Collection<Set<E>>values()Methods inherited from class io.github.douira.glsl_transformer.ast.query.DuplicatorTrie
containsKey, distinctPrefixQuery, get, headMap, nextKey, prefixMap, prefixMapRaw, prepareKey, previousKey, put, 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, replaceAllMethods inherited from interface io.github.douira.glsl_transformer.ast.query.PrefixQueryable
prefixQueryFlatMethods inherited from interface io.github.douira.glsl_transformer.ast.query.SuffixQueryable
suffixQueryFlat
-
Field Details
-
modCount
protected transient int modCount
-
-
Constructor Details
-
PrefixSuffixTrie
public PrefixSuffixTrie() -
PrefixSuffixTrie
-
PrefixSuffixTrie
public PrefixSuffixTrie(char marker) -
PrefixSuffixTrie
-
-
Method Details
-
iterateKeyVariations
- Specified by:
iterateKeyVariationsin classDuplicatorTrie<Set<E>>
-
remove
- Specified by:
removein interfaceGet<String,Set<E>> - Specified by:
removein interfaceMap<String,Set<E>> - Overrides:
removein classDuplicatorTrie<Set<E>>- Parameters:
k- key whose mapping is to be removed from the map- Returns:
- the previous value associated with
key, ornullif there was no mapping forkey. - See Also:
-
prefixQuery
- Specified by:
prefixQueryin interfacePrefixQueryable<E>
-
suffixQuery
- Specified by:
suffixQueryin interfaceSuffixQueryable<E>
-
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
-