makeWritable(); for (Map.Entry<String, Child> e : children.entrySet()) { int plen = commonPrefix(e.getKey(), s); if (plen > 0) { if (plen < e.getKey().length()) { Child middle = c.split(prefix); children.put(prefix, middle); return middle.intern(s.substring(plen)); return e.getValue().intern(s.substring(plen)); children.put(s, t = new Child(new TreeString(node, s)));
/** * Calls {@link TreeString#dedup(Map)} recursively. */ private void dedup(final Map<String, char[]> table) { node.dedup(table); for (Child child : children.values()) { child.dedup(table); } } }
makeWritable(); for (Map.Entry<String, Child> e : children.entrySet()) { int plen = commonPrefix(e.getKey(), s); if (plen > 0) { if (plen < e.getKey().length()) { Child middle = c.split(prefix); children.put(prefix, middle); return middle.intern(s.substring(plen)); return e.getValue().intern(s.substring(plen)); children.put(s, t = new Child(new TreeString(node, s)));
/** * Interns a {@link TreeString} created elsewhere. */ public TreeString intern(final TreeString s) { if (s==null) return null; return root.intern(s.toString()).node; }
/** * Calls {@link TreeString#dedup(Map)} recursively. */ private void dedup(final Map<String, char[]> table) { node.dedup(table); for (Child child : children.values()) { child.dedup(table); } } }
/** * Inserts a new node between this node and its parent, and returns that * node. Newly inserted 'middle' node will have this node as its sole * child. */ private Child split(final String prefix) { String suffix = node.getLabel().substring(prefix.length()); Child middle = new Child(node.split(prefix)); middle.makeWritable(); middle.children.put(suffix, this); return middle; }
/** * Interns a string. */ public TreeString intern(final String s) { if (s==null) return null; return root.intern(s).node; }
/** * Interns a {@link TreeString} created elsewhere. */ public TreeString intern(final TreeString s) { if (s==null) return null; return root.intern(s.toString()).node; }
/** * Interns a string. */ public TreeString intern(final String s) { if (s==null) return null; return root.intern(s).node; }
/** * Inserts a new node between this node and its parent, and returns that * node. Newly inserted 'middle' node will have this node as its sole * child. */ private Child split(final String prefix) { String suffix = node.getLabel().substring(prefix.length()); Child middle = new Child(node.split(prefix)); middle.makeWritable(); middle.children.put(suffix, this); return middle; }