for (Iterator<DetectorNode> i = nodeMap.values().iterator(); i.hasNext();) { DetectorNode node = i.next();
for (DetectorNode node : nodeMap.values()) {
	private void sortPass(			List<DetectorOrderingConstraint> constraintList,			Map<String, DetectorFactory> factoryMap,			AnalysisPass pass)		throws OrderingConstraintException {		// Build set of all (initial) detectors in pass		Set<DetectorFactory> detectorSet = new HashSet<DetectorFactory>(pass.getMembers());		if (DEBUG) {			System.out.println(detectorSet.size() + " detectors currently in this pass");		}				// Build list of ordering constraints in this pass only		List<DetectorOrderingConstraint> passConstraintList =			new LinkedList<DetectorOrderingConstraint>();		for (Iterator<DetectorOrderingConstraint> i = constraintList.iterator(); i.hasNext(); ) {			DetectorOrderingConstraint constraint = i.next();						// Does this constraint specify any detectors in this pass?			// If so, add it to the pass constraints			if (selectDetectors(constraint.getEarlier(), detectorSet).size() > 0					|| selectDetectors(constraint.getLater(), detectorSet).size() > 0) {				passConstraintList.add(constraint);			}		}		if (DEBUG) {			System.out.println(passConstraintList.size() + " constraints are applicable for this pass");		}				// Build set of all detectors available to be added to this pass		HashSet<DetectorFactory> availableSet = new HashSet<DetectorFactory>();		availableSet.addAll(detectorSet);		availableSet.addAll(getUnassignedSet());		// Build intra-pass constraint graph		Map<String, DetectorNode> nodeMap = new HashMap<String, DetectorNode>();		ConstraintGraph constraintGraph = buildConstraintGraph(			nodeMap, availableSet, passConstraintList);		if (DEBUG) {			System.out.println("Pass constraint graph:");			dumpGraph(constraintGraph);		}				// See if any detectors were brought into the pass by an intrapass ordering constraint.		// Assign them to the pass officially.		for (Iterator<DetectorNode> i = nodeMap.values().iterator(); i.hasNext();) {			DetectorNode node = i.next();			if (!pass.contains(node.getFactory())) {				assignToPass(node.getFactory(), pass);			}		}		// Perform DFS, check for cycles		DepthFirstSearch<ConstraintGraph, ConstraintEdge, DetectorNode> dfs =			new DepthFirstSearch<ConstraintGraph, ConstraintEdge, DetectorNode>(constraintGraph);		dfs.search();		if (dfs.containsCycle())			throw new OrderingConstraintException("Cycle in intra-pass ordering constraints!");		// Do a topological sort to put the detectors in the pass		// in the right order.		for (Iterator<DetectorNode> i = dfs.topologicalSortIterator(); i.hasNext(); ) {			DetectorNode node = i.next();			appendToPass(node.getFactory(), pass);		}				// Add any detectors not explicitly involved in intra-pass ordering constraints		// to the end of the pass.		appendDetectorsToPass(pass.getUnpositionedMembers(), pass);	}