List of usage examples for java.util LinkedList containsAll
boolean containsAll(Collection<?> c);
From source file:com.redsqirl.workflow.server.Workflow.java
/** * Do sort of the workflow./*from ww w . j av a 2 s . c om*/ * * If the sort is successful, it is a DAG * * @return null if OK, or a description of the error. * @throws RemoteException */ public String topoligicalSort() throws RemoteException { String error = null; LinkedList<DataFlowElement> newList = new LinkedList<DataFlowElement>(); LinkedList<DataFlowElement> queueList = new LinkedList<DataFlowElement>(); Iterator<DataFlowElement> iconIt = element.iterator(); while (iconIt.hasNext()) { DataFlowElement cur = iconIt.next(); if (cur.getInputComponent().values().size() == 0) { queueList.add(cur); } } while (!queueList.isEmpty()) { newList.add(queueList.removeFirst()); iconIt = element.iterator(); while (iconIt.hasNext()) { DataFlowElement cur = iconIt.next(); if (!newList.contains(cur) && !queueList.contains(cur)) { Iterator<List<DataFlowElement>> it = cur.getInputComponent().values().iterator(); boolean allThere = true; while (it.hasNext() && allThere) { allThere = newList.containsAll(it.next()); } if (allThere) { queueList.add(cur); } } } } if (newList.size() < element.size()) { error = LanguageManagerWF.getText("workflow.topologicalSort"); } else { element = newList; } return error; }