// Path: src/main/java/com/roklenarcic/util/strings/threshold/RangeNodeThreshold.java
// public class RangeNodeThreshold implements Thresholder {
// 
//     private double exponent, linearFactor, maxValue, constantFactor;
// 
//     public RangeNodeThreshold() {
//         this(1);
//     }
// 
//     public RangeNodeThreshold(double exponent) {
//         this(exponent, 1, 0.65, 2);
//     }
// 
//     public RangeNodeThreshold(double exponent, double linearFactor, double maxValue, double constantFactor) {
//         super();
//         this.exponent = exponent;
//         this.linearFactor = linearFactor;
//         this.maxValue = maxValue;
//         this.constantFactor = constantFactor;
//     }
// 
//     public boolean isOverThreshold(int nodeSize, int nodeLevel, int keyIntervalSize) {
//         if (keyIntervalSize <= 8) {
//             return true;
//         }
//         int charArrayCost = (nodeSize / 4) + 3; // Char array costs 24 bytes + 2 bytes per char
//         return nodeSize + charArrayCost > keyIntervalSize * (maxValue - linearFactor / Math.pow(constantFactor + nodeLevel, exponent));
//     }
// 
// }
// 
// Path: src/main/java/com/roklenarcic/util/strings/threshold/Thresholder.java
// public interface Thresholder {
//     boolean isOverThreshold(int nodeSize, int nodeLevel, int keyIntervalSize);
// }


import java.io.IOException;
import java.nio.CharBuffer;
import java.util.Arrays;
import java.util.Iterator;
import com.roklenarcic.util.strings.threshold.RangeNodeThreshold;
import com.roklenarcic.util.strings.threshold.Thresholder;
            return numEntries == 0;
        }

        @Override
        public void mapEntries(EntryVisitor<T> visitor) {
            for (int i = 0; i < keys.length; i++) {
                if (children[i] != null) {
                    visitor.visit(this, keys[i], children[i]);
                }
            }
        }

        @Override
        public void updateTransition(char c, TrieNode<T> node) {
            int defaultSlot = hash(c) & modulusMask;
            int currentSlot = defaultSlot;
            do {
                if (children[currentSlot] == null) {
                    throw new IllegalArgumentException("Transition for " + c + " doesn't exist.");
                } else if (keys[currentSlot] == c) {
                    children[currentSlot] = node;
                    return;
                } else {
                    currentSlot = ++currentSlot & modulusMask;
                }
            } while (currentSlot != defaultSlot);
            throw new IllegalArgumentException("Transition for " + c + " doesn't exist.");
        }

        @Override
// Path: src/main/java/com/roklenarcic/util/strings/threshold/RangeNodeThreshold.java
// public class RangeNodeThreshold implements Thresholder {
// 
//     private double exponent, linearFactor, maxValue, constantFactor;
// 
//     public RangeNodeThreshold() {
//         this(1);
//     }
// 
//     public RangeNodeThreshold(double exponent) {
//         this(exponent, 1, 0.65, 2);
//     }
// 
//     public RangeNodeThreshold(double exponent, double linearFactor, double maxValue, double constantFactor) {
//         super();
//         this.exponent = exponent;
//         this.linearFactor = linearFactor;
//         this.maxValue = maxValue;
//         this.constantFactor = constantFactor;
//     }
// 
//     public boolean isOverThreshold(int nodeSize, int nodeLevel, int keyIntervalSize) {
//         if (keyIntervalSize <= 8) {
//             return true;
//         }
//         int charArrayCost = (nodeSize / 4) + 3; // Char array costs 24 bytes + 2 bytes per char
//         return nodeSize + charArrayCost > keyIntervalSize * (maxValue - linearFactor / Math.pow(constantFactor + nodeLevel, exponent));
//     }
// 
// }
// 
// Path: src/main/java/com/roklenarcic/util/strings/threshold/Thresholder.java
// public interface Thresholder {
//     boolean isOverThreshold(int nodeSize, int nodeLevel, int keyIntervalSize);
// }


// Path: src/main/java/com/roklenarcic/util/strings/LongestMatchMap.java
import java.io.IOException;
import java.nio.CharBuffer;
import java.util.Arrays;
import java.util.Iterator;
import com.roklenarcic.util.strings.threshold.RangeNodeThreshold;
import com.roklenarcic.util.strings.threshold.Thresholder;

            return numEntries == 0;
        }

        @Override
        public void mapEntries(EntryVisitor<T> visitor) {
            for (int i = 0; i < keys.length; i++) {
                if (children[i] != null) {
                    visitor.visit(this, keys[i], children[i]);
                }
            }
        }

        @Override
        public void updateTransition(char c, TrieNode<T> node) {
            int defaultSlot = hash(c) & modulusMask;
            int currentSlot = defaultSlot;
            do {
                if (children[currentSlot] == null) {
                    throw new IllegalArgumentException("Transition for " + c + " doesn't exist.");
                } else if (keys[currentSlot] == c) {
                    children[currentSlot] = node;
                    return;
                } else {
                    currentSlot = ++currentSlot & modulusMask;
                }
            } while (currentSlot != defaultSlot);
            throw new IllegalArgumentException("Transition for " + c + " doesn't exist.");
        }

        @Override
        protected TrieNode<T> optimizeNode(int level, Thresholder thresholdStrategy) {