public synchronized CharTree<V> append(char[] chars, V value) { if (root == null) root = new SingleCharTreeNode<V>(); try { char b = chars[0]; root = root.append(b); CharTreeNode<V> temp = root.next(b); CharTreeNode<V> prev = root; char p = b; for (int i = 1; i < chars.length; i++) { b = chars[i]; CharTreeNode<V> next = temp.append(b); prev.set(p, next); prev = next; temp = next.next(b); p = b; } if (temp.value == null) size++; temp.value = value; } catch (Exception e) { throw new IllegalStateException("Cannot append '" + new String(chars) + "'", e); } return this; }
public CharTree<V> append(char[] chars, V value) { if (root == null) root = new SingleCharTreeNode<V>(); char b = chars[0]; root = root.append(b); CharTreeNode<V> temp = root.next(b); CharTreeNode<V> prev = root; char p = b; for (int i = 1; i < chars.length; i++) { b = chars[i]; CharTreeNode<V> next = temp.append(b); prev.set(p, next); prev = next; temp = next.next(b); p = b; } if (temp.value == null) size++; temp.value = value; return this; }
@Override public CharTreeNode<V> append(char b) { if (next != null && this.b != b) { ArrayCharTreeNode<V> node = new ArrayCharTreeNode<V>(Math.max(this.b, b)); node.set(this.b, next); node.append(b); return node; } else if (this.b == b) return this; else { this.b = b; next = new SingleCharTreeNode<V>(); return this; } }
@Override public CharTreeNode<V> append(char b) { if (next != null && this.b != b) { ArrayCharTreeNode<V> node = new ArrayCharTreeNode<V>(Math.max(this.b, b)); node.set(this.b, next); node.append(b); return node; } else if (this.b == b) return this; else { this.b = b; next = new SingleCharTreeNode<V>(); return this; } }
@Override public CharTreeNode<V> append(char b) { increase(b + 1); if (nodes[b] == null) nodes[b] = new SingleCharTreeNode<V>(); return this; }
@Override public CharTreeNode<V> append(char b) { increase(b + 1); if (nodes[b] == null) nodes[b] = new SingleCharTreeNode<V>(); return this; }