List of usage examples for java.util Queue add
boolean add(E e);
From source file:br.com.autonomiccs.autonomic.administration.plugin.hypervisors.xenserver.XenHypervisor.java
/** * Returns the host password./*ww w . j ava 2 s . c o m*/ */ protected Queue<String> getPassword(Map<String, String> params) { Queue<String> password = new LinkedList<>(); password.add(params.get("password")); return password; }
From source file:com.streamsets.pipeline.lib.jdbc.multithread.TestMultithreadedTableProvider.java
private static MultithreadedTableProvider createProvider(Collection<TableRuntimeContext> partitions) { Map<String, TableContext> tableContexts = new HashMap<>(); Queue<String> tableOrder = new LinkedList<>(); for (TableRuntimeContext partition : partitions) { TableContext table = partition.getSourceTableContext(); final String tableName = table.getQualifiedName(); tableContexts.put(tableName, table); tableOrder.add(tableName); }//from w w w . j a v a 2 s .c o m return new MultithreadedTableProvider(tableContexts, tableOrder, Collections.emptyMap(), 1, BatchTableStrategy.SWITCH_TABLES); }
From source file:org.kuali.rice.krad.uif.lifecycle.ApplyModelComponentPhase.java
/** * Applies the model data to a component of the View instance * * <p>/*from w w w. ja v a 2s . c o m*/ * TODO: Revise - The component is invoked to to apply the model data. Here the component can * generate any additional fields needed or alter the configured fields. After the component is * invoked a hook for custom helper service processing is invoked. Finally the method is * recursively called for all the component children * </p> * * {@inheritDoc} */ @Override protected void initializePendingTasks(Queue<ViewLifecycleTask<?>> tasks) { tasks.add(LifecycleTaskFactory.getTask(PopulateComponentContextTask.class, this)); tasks.add(LifecycleTaskFactory.getTask(EvaluateExpressionsTask.class, this)); tasks.add(LifecycleTaskFactory.getTask(SyncClientSideStateTask.class, this)); tasks.add(LifecycleTaskFactory.getTask(ApplyAuthAndPresentationLogicTask.class, this)); if (ViewLifecycle.isRefreshComponent(getViewPhase(), getViewPath())) { tasks.add(LifecycleTaskFactory.getTask(RefreshStateModifyTask.class, this)); } tasks.add(LifecycleTaskFactory.getTask(ComponentDefaultApplyModelTask.class, this)); getElement().initializePendingTasks(this, tasks); tasks.offer(LifecycleTaskFactory.getTask(RunComponentModifiersTask.class, this)); tasks.add(LifecycleTaskFactory.getTask(HelperCustomApplyModelTask.class, this)); tasks.add(LifecycleTaskFactory.getTask(SetReadOnlyOnDataBindingTask.class, this)); }
From source file:DecorateMutationsSNP.java
/** * This function returns the set of leaves in the ARG that are reachable from a node give in input * @param root integer value representing the ID of the node in the arg * @param arg object of the class PopulationARG * @see PopulationARG/*www. j a v a2 s . c o m*/ * @see Node * @return the set of integer values representing the leaves in the ARG that are reachable from a node give in input (root) */ public static TreeSet<Integer> computeLeaves(int root, PopulationARG arg) { TreeSet<Integer> leaves = new TreeSet<Integer>(); Queue<Integer> q = new LinkedList<Integer>(); boolean visited[] = new boolean[arg.getNodeSet().size()]; /*System.out.println("ID Population = "+arg.getId_pop()); System.out.println("Population Kind = "+arg.getKind()); System.out.println("Extant units = "+arg.getExtantUnits()); System.out.println("Node set size = "+arg.getNodeSet().size());*/ for (int i = 0; i < visited.length; i++) { visited[i] = false; } //System.out.println("Root = "+root); //If root is a leaf I have to add just that leaf in leaves, no reason to do the visit if (root >= 0 && root < arg.getExtantUnits()) { leaves.add(new Integer(root)); } //Else bfv to search for all the leaves of the subtree with root root else { visited[root] = true; q.add(new Integer(root)); while (!q.isEmpty()) { // remove a labeled vertex from the queue int w = ((Integer) q.remove()).intValue(); // mark unreached vertices adjacent from w Iterator<Integer> it_edges = arg.getGraphEdges().keySet().iterator(); while (it_edges.hasNext()) { Integer keyE = it_edges.next(); Edge e = arg.getGraphEdges().get(keyE); //if I have found an edge with w has father if (e.getId_fath() == w) { int u = e.getId_son(); //System.out.println("Visiting edge "+w+"-"+u); if (!visited[u]) { q.add(new Integer(u)); visited[u] = true; //System.out.println("Visiting node :"+u); if (u >= 0 && u < arg.getExtantUnits()) { //System.out.println("u is a leaf :"+u); //u is a leaf node leaves.add(u); } } } //end if w is a father of the edge } //for all edge..select the one that has w has father and take u as son } //end while } // end else root is not a leaf return leaves; }
From source file:org.phenotips.solr.HPOScriptService.java
/** * Get the HPO IDs of the specified phenotype and all its ancestors. * * @param id the HPO identifier to search for, in the {@code HP:1234567} format * @return the full set of ancestors-or-self IDs, or an empty set if the requested ID was not found in the index *//* www . j a v a 2 s . com*/ @SuppressWarnings("unchecked") public Set<String> getAllAncestorsAndSelfIDs(final String id) { Set<String> results = new HashSet<String>(); Queue<SolrDocument> nodes = new LinkedList<SolrDocument>(); SolrDocument crt = this.get(id); if (crt == null) { return results; } nodes.add(crt); while (!nodes.isEmpty()) { crt = nodes.poll(); results.add(String.valueOf(crt.get(ID_FIELD_NAME))); Object rawParents = crt.get("is_a"); if (rawParents == null) { continue; } List<String> parents; if (rawParents instanceof String) { parents = Collections.singletonList(String.valueOf(rawParents)); } else { parents = (List<String>) rawParents; } for (String pid : parents) { nodes.add(this.get(StringUtils.substringBefore(pid, " "))); } } return results; }
From source file:org.bigwiv.blastgraph.SubSetCluster.java
@Override public Set<Set<V>> transform(UndirectedGraph<V, E> theGraph) { Set<Set<V>> subSets = new LinkedHashSet<Set<V>>(); if (theGraph.getVertices().isEmpty()) return subSets; isVisited = new HashMap<V, Number>(); for (V v : theGraph.getVertices()) { isVisited.put(v, 0);/* w w w. j a v a 2s. com*/ } for (V v : theGraph.getVertices()) { if (isVisited.get(v).intValue() == 0) { Set<V> subSet = new HashSet<V>(); subSet.add(v); // Stack<V> toVisitStack = new Stack<V>();//stack for DFS // toVisitStack.push(v); // // while (toVisitStack.size() != 0) { // V curV = toVisitStack.pop(); // isVisited.put(curV, 1); // for (V w : theGraph.getNeighbors(curV)) { // if (isVisited.get(w).intValue() == 0) // w hasn't yet // // been visited // { // subSet.add(w); // toVisitStack.push(w); // } // } // // } Queue<V> toVisitQueue = new LinkedList<V>();//Queue for BFS toVisitQueue.add(v); while (toVisitQueue.size() != 0) { V curV = toVisitQueue.remove(); isVisited.put(curV, 1); for (V w : theGraph.getNeighbors(curV)) { if (isVisited.get(w).intValue() == 0) // w hasn't yet // been visited { subSet.add(w); toVisitQueue.add(w); } } } subSets.add(subSet); } } return subSets; }
From source file:org.jbpm.services.task.jaxb.ComparePair.java
public void recursiveCompare() { Queue<ComparePair> compares = new LinkedList<ComparePair>(); compares.add(this); while (!compares.isEmpty()) { compares.addAll(compares.poll().compare()); }/*from ww w . jav a 2s . c o m*/ }
From source file:io.cloudslang.lang.tools.build.validation.StaticValidatorImpl.java
private void validateInOutParams(Map<String, String> metadataInOutParams, List<? extends InOutParam> inOutParams, String errorMessagePrefix, Queue<RuntimeException> exceptions) { for (InOutParam inOutParam : ListUtils.emptyIfNull(inOutParams)) { if (MapUtils.isEmpty(metadataInOutParams)) { exceptions.add( new MetadataMissingException(errorMessagePrefix + "s are missing description entirely.")); } else if (metadataInOutParams.get(inOutParam.getName()) == null && (!(inOutParam instanceof Input) || !((Input) inOutParam).isPrivateInput())) { exceptions.add(new MetadataMissingException( errorMessagePrefix + " '" + inOutParam.getName() + "' is missing description.")); }/*from w ww . j a va 2 s . co m*/ } }
From source file:com.facebook.config.AbstractExpandedConfJSONProvider.java
private JSONObject getExpandedJSONConfig() throws JSONException { Set<String> traversedFiles = new HashSet<>(); Queue<String> toTraverse = new LinkedList<>(); // Seed the graph traversal with the root node traversedFiles.add(root);// ww w . j a v a2s . c o m toTraverse.add(root); // Policy: parent configs will override children (included) configs JSONObject expanded = new JSONObject(); while (!toTraverse.isEmpty()) { String current = toTraverse.remove(); JSONObject json = load(current); JSONObject conf = json.getJSONObject(CONF_KEY); Iterator<String> iter = conf.keys(); while (iter.hasNext()) { String key = iter.next(); // Current config will get to insert keys before its include files if (!expanded.has(key)) { expanded.put(key, conf.get(key)); } } // Check if the file itself has any included files if (json.has(INCLUDES_KEY)) { JSONArray includes = json.getJSONArray(INCLUDES_KEY); for (int idx = 0; idx < includes.length(); idx++) { String include = resolve(current, includes.getString(idx)); if (traversedFiles.contains(include)) { LOG.warn("Config file was included twice: " + include); } else { toTraverse.add(include); traversedFiles.add(include); } } } } return expanded; }