Changeset 1040 for trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/IterativeDFSFilterStrategy.java
- Timestamp:
- 01/16/13 17:51:51 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/IterativeDFSFilterStrategy.java
r1030 r1040 1 // Copyright 2012 Georg-August-Universität Göttingen, Germany 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 1 15 package de.ugoe.cs.autoquest.usability.tasktree.filter; 2 16 … … 10 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 11 25 26 /** 27 * <p> 28 * TODO comment 29 * </p> 30 * 31 * @author Alexander Deicke 32 */ 12 33 public class IterativeDFSFilterStrategy implements TaskTreeFilterStrategy { 13 34 14 35 private FilterStatistic filterStatistic; 15 36 16 37 @SuppressWarnings("unchecked") 17 38 @Override … … 31 52 return this.filterStatistic; 32 53 } 33 54 55 @SuppressWarnings("unchecked") 56 @Override 57 public FilterStatistic filter(ITaskTree taskTree, TaskTreeNodeTypeFilter nodeType) { 58 Predicate<ITaskTreeNode> filterPredicate = nodeType.filterPredicate(); 59 this.filterStatistic = new FilterStatistic(filterPredicate); 60 traverse(taskTree); 61 return this.filterStatistic; 62 } 63 34 64 private void traverse(ITaskTree taskTree) { 35 65 Stack<ITaskTreeNode> unvisitedNodes = new Stack<ITaskTreeNode>(); 36 66 unvisitedNodes.push(taskTree.getRoot()); 37 while (stillUnvisitedNodes(unvisitedNodes)) {67 while (stillUnvisitedNodes(unvisitedNodes)) { 38 68 ITaskTreeNode node = unvisitedNodes.pop(); 39 69 processCurrentNode(node); … … 49 79 this.filterStatistic.addNode(node); 50 80 } 51 81 52 82 private void processChildrenOfCurrentNode(Stack<ITaskTreeNode> unvisitedNodes, 53 ITaskTreeNode node) { 54 for(ITaskTreeNode child : node.getChildren()) { 83 ITaskTreeNode node) 84 { 85 for (ITaskTreeNode child : node.getChildren()) { 55 86 unvisitedNodes.push(child); 56 87 }
Note: See TracChangeset
for help on using the changeset viewer.