Changeset 1118 for trunk/autoquest-core-usageprofiles
- Timestamp:
- 03/06/13 23:38:19 (12 years ago)
- Location:
- trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/Trie.java
r1110 r1118 121 121 /** 122 122 * <p> 123 * Trains the current trie using the given sequence and adds all subsequence of length123 * Trains the current trie using the given sequence and adds all subsequences of length 124 124 * {@code maxOrder}. 125 125 * </p> … … 145 145 } 146 146 int sequenceLength = sequence.size(); 147 for (int j = maxOrder - 1; j > 0; j--) { 148 add(sequence.subList(sequenceLength - j, sequenceLength)); 147 int startIndex = Math.max(0, sequenceLength - maxOrder + 1); 148 for (int j = startIndex; j < sequenceLength; j++) { 149 add(sequence.subList(j, sequenceLength)); 149 150 } 150 151 } … … 320 321 321 322 return contextSuffix; 323 } 324 325 /** 326 * 327 */ 328 public void process(TrieProcessor<T> processor) { 329 LinkedList<T> context = new LinkedList<T>(); 330 331 for (TrieNode<T> child : rootNode.getChildren()) { 332 if (!process(context, child, processor)) { 333 break; 334 } 335 } 336 } 337 338 /** 339 * <p> 340 * TODO: comment 341 * </p> 342 * @param context 343 * 344 * @param child 345 * @param processor 346 */ 347 private boolean process(LinkedList<T> context, 348 TrieNode<T> node, 349 TrieProcessor<T> processor) 350 { 351 context.add(node.getSymbol()); 352 353 TrieProcessor.Result result = processor.process(context, node.getCount()); 354 355 if (result == TrieProcessor.Result.CONTINUE) { 356 for (TrieNode<T> child : node.getChildren()) { 357 if (!process(context, child, processor)) { 358 break; 359 } 360 } 361 } 362 363 context.removeLast(); 364 365 return result != TrieProcessor.Result.BREAK; 322 366 } 323 367
Note: See TracChangeset
for help on using the changeset viewer.