List of usage examples for java.util Queue add
boolean add(E e);
From source file:com.insightml.utils.types.collections.PairList.java
public Queue<F> keys() { final Queue<F> values = new LinkedList<>(); for (final Pair<F, S> entry : list) { values.add(entry.getFirst()); }/*from w w w . j a va2 s .c o m*/ return values; }
From source file:org.archive.bdb.StoredQueueTest.java
protected void fill(java.util.Queue<String> q, int size) { for (int i = 1; i <= size; i++) { q.add("item-" + i); }/* ww w.ja v a 2s. co m*/ }
From source file:org.opentestsystem.airose.docprocessors.ConventionsQualityDocProcessor.java
private ConventionsDocumentQualityHolder evaluateSyntax(Parse parse) { double overallPunctScore = 0.0; double minSyntaxScore = 1.0; double overallSyntaxScore = 0.0; double numOfNoms = 0; double numLongNominals = 0; double syntaxCount = 0; int countPunct = 0; Queue<Parse> parseTree = new LinkedList<Parse>(); parseTree.add(parse); double rootProb = parse.getProb(); while (parseTree.size() > 0) { Parse p = parseTree.remove();/*from ww w .j a v a2 s. co m*/ if ((p.getChildCount() == 1) && (p.getProb() < 1)) { double prob = p.getProb(); String pType = p.getType(); if (StringUtils.equals(pType, ",") || StringUtils.equals(pType, ".") || StringUtils.equals(pType, "!") || StringUtils.equals(pType, "?") || StringUtils.equals(pType, ";") || StringUtils.equals(pType, ":")) { overallPunctScore += prob; countPunct++; } else { if (!StringUtils.equals(pType, "TOP") && !StringUtils.equals(pType, "S")) { // string s = sentText_; if ((pType.startsWith("NN")))// || p.Type.StartsWith("JJ")) { numOfNoms++; } else { if ((numOfNoms > 2) && (rootProb > -25.5)) numLongNominals++; // _numOfNoms = 0; } if (prob < minSyntaxScore) minSyntaxScore = prob; overallSyntaxScore += prob; syntaxCount++; } } } Parse[] children = p.getChildren(); for (Parse pc : children) parseTree.add(pc); } overallPunctScore = (countPunct == 0) ? 0.0 : overallPunctScore / countPunct; ConventionsDocumentQualityHolder values = new ConventionsDocumentQualityHolder(); values.setOverallPunctScore(overallPunctScore); values.setMinSyntaxScore(minSyntaxScore); values.setOverallSyntaxScore(overallSyntaxScore); values.setNumOfNoms(numOfNoms); values.setNumLongNominals(numLongNominals); values.setSyntaxCount(syntaxCount); return values; }
From source file:org.opennms.features.vaadin.topology.jung.BalloonLayoutAlgorithm.java
public void updateLayout(GraphContainer graph) { Graph g = new Graph(graph); int szl = g.getSemanticZoomLevel(); Vertex rootItem = g.getDisplayVertex(g.getVertexByItemId(m_rootItemId), szl); Tree<Vertex, Edge> tree = new OrderedKAryTree<Vertex, Edge>(50); Queue<Vertex> q = new LinkedList<Vertex>(); Set<Vertex> found = new HashSet<Vertex>(); q.add(rootItem); tree.addVertex(rootItem);//from w w w . j a va 2s . com Vertex v; while ((v = q.poll()) != null) { List<Edge> edges = g.getEdgesForVertex(v, szl); for (Edge e : edges) { Vertex neighbor = e.getSource() != v ? e.getSource() : e.getTarget(); tree.addEdge(e, v, neighbor); if (!found.contains(neighbor)) { q.add(neighbor); } } } BalloonLayout<Vertex, Edge> layout = new BalloonLayout<Vertex, Edge>(tree); layout.setInitializer(new Transformer<Vertex, Point2D>() { public Point2D transform(Vertex v) { return new Point(v.getX(), v.getY()); } }); for (Vertex vertex : g.getVertices(szl)) { layout.lock(vertex, vertex.isLocked()); } layout.setSize(new Dimension(750, 750)); List<Vertex> vertices = g.getVertices(szl); for (Vertex vertex : vertices) { Point2D point = layout.transform(v); vertex.setX((int) point.getX()); vertex.setY((int) point.getY()); } }
From source file:org.silverpeas.tools.file.regexpr.RegExprMatcher.java
private void analyse(File startFile) throws Exception { Queue<File> fileQueue = new ArrayDeque<>(100000); fileQueue.add(startFile); while (!fileQueue.isEmpty()) { File file = fileQueue.poll(); if (file.isFile()) { if (config.getFileFilter().accept(file)) { boolean fileMatched = false; for (PatternConfig patternConfig : config.getPatternConfigs()) { boolean found = patternConfig.pattern.matcher(FileUtils.readFileToString(file)).find(); fileMatched = (found && patternConfig.mustMatch) || (!found && !patternConfig.mustMatch); if (!fileMatched) { break; }//from w w w . ja v a 2 s .c o m } if (fileMatched) { System.out.println(file.getPath()); nbMatchedFiles++; } nbAnalysedFiles++; } } else if (file.isDirectory() && config.getDirFilter().accept(file)) { for (File subFile : file.listFiles()) { fileQueue.add(subFile); } } else { int i = 0; } } }
From source file:org.kantega.notsoserial.CreateBytesIT.java
private Object nastySerializable() { InvokerTransformer transformer = new InvokerTransformer("toString", new Class[] {}, new Object[] {}); Queue priorityQueue = new PriorityQueue(2, new TransformingComparator(transformer)); priorityQueue.add(1); priorityQueue.add(1);/*from ww w . j a v a 2 s. c o m*/ TemplatesImpl templates = createTemplates(); setFieldValue(transformer, "iMethodName", "newTransformer"); Object[] queue = (Object[]) getFieldValue(priorityQueue, "queue"); queue[0] = templates; queue[1] = templates; return priorityQueue; }
From source file:org.rhq.modules.plugins.wildfly10.itest.standalone.TemplatedResourcesTest.java
@Test(priority = 11) public void loadUpdateTemplatedResourceConfiguration() throws Exception { ConfigurationManager configurationManager = this.pluginContainer.getConfigurationManager(); for (ResourceData resourceData : testResourceData) { ResourceType resourceType = new ResourceType(resourceData.resourceTypeName, Constants.PLUGIN_NAME, ResourceCategory.SERVICE, null); Resource subsystem = waitForResourceByTypeAndKey(platform, server, resourceType, resourceData.resourceKey); Assert.assertNotNull(subsystem); Queue<Resource> unparsedResources = new LinkedList<Resource>(); unparsedResources.add(subsystem); List<Resource> foundResources = new ArrayList<Resource>(); while (!unparsedResources.isEmpty()) { Resource currentResource = unparsedResources.poll(); for (Resource childResource : currentResource.getChildResources()) { unparsedResources.add(childResource); if (childResource.getResourceType().getName().equals(resourceData.subResourceType)) { foundResources.add(childResource); }//from w w w .ja va2 s .c om } } for (Resource resourceUnderTest : foundResources) { log.info(foundResources); assert resourceUnderTest .getId() != 0 : "Resource not properly initialized. Id = 0. Try extending sleep after discovery."; Configuration resourceUnderTestConfig = configurationManager .loadResourceConfiguration(resourceUnderTest.getId()); Assert.assertNotNull(resourceUnderTestConfig); Assert.assertFalse(resourceUnderTestConfig.getProperties().isEmpty()); boolean specialPropertyFound = false; for (Property property : resourceUnderTestConfig.getProperties()) { if (property.getName().equals(resourceData.specialConfigurationProperty)) { Assert.assertNotNull(((PropertySimple) property).getStringValue()); specialPropertyFound = true; break; } } Assert.assertTrue(specialPropertyFound, resourceData.specialConfigurationProperty + "property not found in the list of properties"); ConfigurationUpdateRequest testUpdateRequest = new ConfigurationUpdateRequest(1, resourceUnderTestConfig, resourceUnderTest.getId()); ConfigurationUpdateResponse response = configurationManager .executeUpdateResourceConfigurationImmediately(testUpdateRequest); Assert.assertNotNull(response); } } }
From source file:com.davidsoergel.trees.RootedPhylogenyInterfaceTest.java
@Override public void addContractTestsToQueue(Queue theContractTests) { theContractTests.add(new PhylogenyNodeInterfaceTest<T>(tif)); theContractTests.add(new TaxonMergingPhylogenyInterfaceTest<T>(tif)); }
From source file:org.rhq.modules.plugins.jbossas7.itest.standalone.TemplatedResourcesTest.java
@Test(priority = 11) public void loadUpdateTemplatedResourceConfiguration() throws Exception { ConfigurationManager configurationManager = this.pluginContainer.getConfigurationManager(); for (ResourceData resourceData : testResourceData) { ResourceType resourceType = new ResourceType(resourceData.resourceTypeName, PLUGIN_NAME, ResourceCategory.SERVICE, null); Resource subsystem = waitForResourceByTypeAndKey(platform, server, resourceType, resourceData.resourceKey); Assert.assertNotNull(subsystem); Queue<Resource> unparsedResources = new LinkedList<Resource>(); unparsedResources.add(subsystem); List<Resource> foundResources = new ArrayList<Resource>(); while (!unparsedResources.isEmpty()) { Resource currentResource = unparsedResources.poll(); for (Resource childResource : currentResource.getChildResources()) { unparsedResources.add(childResource); if (childResource.getResourceType().getName().equals(resourceData.subResourceType)) { foundResources.add(childResource); }// w w w . j av a2 s . c o m } } for (Resource resourceUnderTest : foundResources) { log.info(foundResources); assert resourceUnderTest .getId() != 0 : "Resource not properly initialized. Id = 0. Try extending sleep after discovery."; Configuration resourceUnderTestConfig = configurationManager .loadResourceConfiguration(resourceUnderTest.getId()); Assert.assertNotNull(resourceUnderTestConfig); Assert.assertFalse(resourceUnderTestConfig.getProperties().isEmpty()); boolean specialPropertyFound = false; for (Property property : resourceUnderTestConfig.getProperties()) { if (property.getName().equals(resourceData.specialConfigurationProperty)) { Assert.assertNotNull(((PropertySimple) property).getStringValue()); specialPropertyFound = true; break; } } Assert.assertTrue(specialPropertyFound, resourceData.specialConfigurationProperty + "property not found in the list of properties"); ConfigurationUpdateRequest testUpdateRequest = new ConfigurationUpdateRequest(1, resourceUnderTestConfig, resourceUnderTest.getId()); ConfigurationUpdateResponse response = configurationManager .executeUpdateResourceConfigurationImmediately(testUpdateRequest); Assert.assertNotNull(response); } } }
From source file:graph.inference.module.TransitiveWorker.java
protected void transitiveSearch(QueryObject queryObj) { // Find the index int atomicIndex = queryObj.getAtomicIndex(); int varIndex = (atomicIndex == 1) ? 2 : 1; DAGNode atomic = queryObj.getAtomic(); if (atomic == null) return;//from www .j a va 2 s . c o m Queue<DAGNode> toCheck = new LinkedList<>(); toCheck.add(atomic); Collection<Edge> genlEdges = relatedModule_.findEdgeByNodes((DAGNode) queryObj.getNode(0)); while (!toCheck.isEmpty()) { DAGNode n = querier_.getExpanded(toCheck.poll()); if (queryObj.isCompleted(n)) continue; queryObj.addCompleted(n); // Function checking if (atomicIndex == 1 && n instanceof OntologyFunction) { Collection<DAGNode> functionEdges = querier_.functionResults((OntologyFunction) n, CommonConcepts.RESULT_GENL); for (DAGNode resultNode : functionEdges) { if (queryObj.isProof() && resultNode.equals(queryObj.getNode(2))) { queryObj.addResult(new Substitution(), CommonConcepts.GENLS.getNode(dag_), n, resultNode); return; } if (queryObj.addResult(CommonConcepts.GENLS.getNode(dag_), n, resultNode)) return; toCheck.add(resultNode); } } // Intersect the collections Collection<Edge> nodeEdges = relatedModule_.execute(n, atomicIndex + 1); nodeEdges = CollectionUtils.retainAll(nodeEdges, genlEdges); // Self genls check if (n == atomic) { Collection<Edge> selfEdges = nodeEdges; if (selfEdges.isEmpty()) { selfEdges = relatedModule_.execute(atomic, varIndex + 1); selfEdges = CollectionUtils.retainAll(selfEdges, genlEdges); } if (!selfEdges.isEmpty()) { if (queryObj.addResult(queryObj.getNode(0), atomic, n)) return; } } // Create the subs for (Edge e : nodeEdges) { if (!(e.getNodes()[varIndex] instanceof DAGNode)) continue; DAGNode edgeNode = (DAGNode) e.getNodes()[varIndex]; if (queryObj.isProof() && e.getNodes()[varIndex].equals(queryObj.getNode(2))) { queryObj.addResult(new Substitution(), e.getNodes()); return; } if (queryObj.addResult(e.getNodes())) return; toCheck.add(edgeNode); } } }