Changeset 1251 for trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/TrieNode.java
- Timestamp:
- 07/12/13 16:45:53 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/TrieNode.java
r1189 r1251 67 67 * </p> 68 68 */ 69 private Collection<TrieNode<T>> children;70 69 private SymbolMap<T, TrieNode<T>> children; 70 71 71 /** 72 72 * <p> … … 115 115 this.symbol = null; 116 116 count = 0; 117 children = new LinkedList<TrieNode<T>>();117 children = new SymbolMap<T, TrieNode<T>>(this.comparator); 118 118 } 119 119 … … 140 140 141 141 count = 0; 142 children = new LinkedList<TrieNode<T>>();142 children = new SymbolMap<T, TrieNode<T>>(this.comparator); 143 143 } 144 144 … … 157 157 count = other.count; 158 158 comparator = other.comparator; 159 children = new LinkedList<TrieNode<T>>(); 160 for (TrieNode<T> child : other.children) { 161 children.add(new TrieNode<T>(child)); 159 children = new SymbolMap<T, TrieNode<T>>(this.comparator); 160 161 for (TrieNode<T> child : other.children.getValues()) { 162 children.addSymbol(child.getSymbol(), new TrieNode<T>(child)); 162 163 } 163 164 } … … 224 225 if (node == null) { 225 226 node = new TrieNode<T>(symbol, comparator); 226 children.add (node);227 children.addSymbol(symbol, node); 227 228 } 228 229 return node; … … 240 241 */ 241 242 protected TrieNode<T> getChild(T symbol) { 242 for (TrieNode<T> child : children) { 243 if (comparator.equals(child.getSymbol(), symbol)) { 244 return child; 245 } 246 } 247 return null; 243 return children.getValue(symbol); 248 244 } 249 245 … … 256 252 */ 257 253 protected Collection<TrieNode<T>> getChildren() { 258 return children ;254 return children.getValues(); 259 255 } 260 256 … … 296 292 public Collection<T> getFollowingSymbols() { 297 293 Collection<T> followingSymbols = new LinkedList<T>(); 298 for (TrieNode<T> child : children ) {294 for (TrieNode<T> child : children.getValues()) { 299 295 followingSymbols.add(child.getSymbol()); 300 296 } … … 346 342 graph.addChild(new Edge(), parent, currentVertex); 347 343 } 348 for (TrieNode<T> node : children ) {344 for (TrieNode<T> node : children.getValues()) { 349 345 node.getGraph(currentVertex, graph); 350 346 } … … 370 366 stringBuilder.append(" " + hashCode() + " [label=\"" + thisSaneId + "\"];" + 371 367 StringTools.ENDLINE); 372 for (TrieNode<T> childNode : children ) {368 for (TrieNode<T> childNode : children.getValues()) { 373 369 stringBuilder.append(" " + hashCode() + " -> " + childNode.hashCode() + ";" + 374 370 StringTools.ENDLINE); 375 371 } 376 for (TrieNode<T> childNode : children ) {372 for (TrieNode<T> childNode : children.getValues()) { 377 373 childNode.appendDotRepresentation(stringBuilder); 378 374 } … … 412 408 protected void getLeafAncestors(List<TrieNode<T>> ancestors) { 413 409 boolean isAncestor = false; 414 for (TrieNode<T> child : children ) {410 for (TrieNode<T> child : children.getValues()) { 415 411 child.getLeafAncestors(ancestors); 416 412 isAncestor |= child.isLeaf(); … … 431 427 protected int getNumLeafs() { 432 428 int numLeafs = 0; 433 for (TrieNode<T> child : children ) {429 for (TrieNode<T> child : children.getValues()) { 434 430 if (child.isLeaf()) { 435 431 numLeafs++;
Note: See TracChangeset
for help on using the changeset viewer.