Class FrequencyTrie.Builder<V>
- Type Parameters:
V- value type
- Enclosing class:
FrequencyTrie<V>
FrequencyTrie.
The builder is intentionally mutable and optimized for repeated
put(String, Object) calls. The final trie is created by
build(), which performs bottom-up subtree reduction and converts the
structure to a compact immutable representation optimized for read
operations.
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder(IntFunction<V[]> arrayFactory, ReductionMode reductionMode) Creates a new builder using default thresholds for the supplied reduction mode.Builder(IntFunction<V[]> arrayFactory, ReductionSettings reductionSettings) Creates a new builder with the provided settings. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a compiled read-only trie.Stores a value for the supplied key and increments its local frequency.Stores a value for the supplied key and increments its local frequency by the specified positive count.
-
Constructor Details
-
Builder
Creates a new builder with the provided settings.- Parameters:
arrayFactory- array factoryreductionSettings- reduction configuration- Throws:
NullPointerException- if any argument isnull
-
Builder
Creates a new builder using default thresholds for the supplied reduction mode.- Parameters:
arrayFactory- array factoryreductionMode- reduction mode- Throws:
NullPointerException- if any argument isnull
-
-
Method Details
-
put
Stores a value for the supplied key and increments its local frequency.Values are stored at the node addressed by the full key. Since trie values may also appear on internal nodes, an empty key is valid and stores a value directly at the root.
- Parameters:
key- keyvalue- value- Returns:
- this builder
- Throws:
NullPointerException- ifkeyorvalueisnull
-
build
Builds a compiled read-only trie.- Returns:
- compiled trie
-
put
Stores a value for the supplied key and increments its local frequency by the specified positive count.Values are stored at the node addressed by the full key. Since trie values may also appear on internal nodes, an empty key is valid and stores a value directly at the root.
This method is functionally equivalent to calling
put(String, Object)repeatedlycounttimes, but it avoids unnecessary repeated map updates and is therefore preferable for bulk reconstruction from compiled tries or other aggregated sources.- Parameters:
key- keyvalue- valuecount- positive frequency increment- Returns:
- this builder
- Throws:
NullPointerException- ifkeyorvalueisnullIllegalArgumentException- ifcountis less than1
-