Warning: session_start(): open(/var/lib/php/sessions/sess_2lls26r1736bh4vip4n14o902o, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// A = type of value in nodes.
// Can be case-sensitive or case-insensitive
// values can't be null
sclass StringTrie {
A value;
TreeMap> children;
*() {}
*(A *value) {}
void makeCaseInsensitive() {
children = asCIMap(children);
}
bool isCaseInsensitive() {
ret isCIMap(children);
}
void add(S string, A value) {
if (empty(string)) ret with this.value = value;
S existingPrefix = isCaseInsensitive()
? longestPrefixInCISet(string, navigableKeys(children))
: longestPrefixInNavigableSet(string, navigableKeys(children));
if (nempty(existingPrefix))
ret with children.get(existingPrefix).add(substring(string, l(existingPrefix)), value);
if (children == null) children = new TreeMap;
StringTrie child = new(value);
if (isCaseInsensitive()) child.makeCaseInsensitive();
children.put(string, child);
}
// returns TreeMap or ciMap
Map asMap() {
Map = isCaseInsensitive() ? ciMap() : new TreeMap;
new StringBuilder buf;
collectMap(buf, map);
}
private void collectMap(StringBuilder buf, Map map) {
if (value != null) map.put(str(buf), value);
int n = l(buf);
for (S string, StringTrie child : children) {
buf.add(string);
child.collectMap(buf, map);
buf.setSize(n);
}
}
}