(final String component)
| 197 | } |
| 198 | |
| 199 | public Trie append(final String component) { |
| 200 | int index = binarySearch(children, nchildren, component); |
| 201 | if(index >= 0) { |
| 202 | return children[index]; |
| 203 | } |
| 204 | |
| 205 | Trie nt = new Trie(this,component); |
| 206 | index = -index - 1; // calculate insertion point |
| 207 | |
| 208 | if((nchildren+1) < children.length) { |
| 209 | System.arraycopy(children, index, children, index+1, nchildren - index); |
| 210 | } else { |
| 211 | Trie[] tmp = new Trie[children.length * 2]; |
| 212 | System.arraycopy(children, 0, tmp, 0, index); |
| 213 | System.arraycopy(children, index, tmp, index+1, nchildren - index); |
| 214 | children = tmp; |
| 215 | } |
| 216 | |
| 217 | children[index] = nt; |
| 218 | nchildren++; |
| 219 | return nt; |
| 220 | } |
| 221 | |
| 222 | public Trie append(final Trie t) { |
| 223 | Trie r = this; |
no test coverage detected