List of usage examples for java.util LinkedList addAll
public boolean addAll(Collection<? extends E> c)
From source file:org.trnltk.experiment.bruteforce.BruteForceExperiments.java
@Test public void shouldParseTbmmJournal_b0241h_andCreateRootHistogram() throws IOException { final File tokenizedFile = new File("core/src/test/resources/tokenizer/tbmm_b0241h_tokenized.txt"); final List<String> lines = Files.readLines(tokenizedFile, Charsets.UTF_8); final LinkedList<String> words = new LinkedList<String>(); for (String line : lines) { words.addAll(Lists.newArrayList(Splitter.on(" ").trimResults().omitEmptyStrings().split(line))); }/*w ww . j av a 2 s.c om*/ final HashMultiset<Root> roots = HashMultiset.create(words.size() * 4); final HashMultiset<String> lemmas = HashMultiset.create(words.size() * 4); for (String word : words) { final LinkedList<MorphemeContainer> morphemeContainers = parser.parse(new TurkishSequence(word)); if (morphemeContainers.isEmpty()) System.out.println("Word is not parsable " + word); final List<Root> rootsForWord = Lists.transform(morphemeContainers, new Function<MorphemeContainer, Root>() { @Override public Root apply(MorphemeContainer input) { return input.getRoot(); } }); final List<String> lemmasForWord = Lists.transform(morphemeContainers, new Function<MorphemeContainer, String>() { @Override public String apply(MorphemeContainer input) { return input.getRoot().getLexeme().getLemma(); } }); roots.addAll(rootsForWord); lemmas.addAll(lemmasForWord); if (roots.size() > 50000) break; } System.out.println("Found lemma count " + lemmas.size()); final ImmutableMultiset<String> lemmasSortedByCount = Multisets.copyHighestCountFirst(lemmas); for (Multiset.Entry<String> stringEntry : lemmasSortedByCount.entrySet()) { final String lemma = stringEntry.getElement(); final int count = stringEntry.getCount(); System.out.println(String.format("%5d ", count) + lemma); } System.out.println("Found root count " + roots.size()); // final ImmutableMultiset<Root> rootsSortedByCount = Multisets.copyHighestCountFirst(roots); // for (Multiset.Entry<Root> rootEntry : rootsSortedByCount.entrySet()) { // final Root root = rootEntry.getElement(); // final int count = rootEntry.getCount(); // System.out.println(String.format("%5d ", count) + root.toString()); // } }
From source file:com.act.reachables.CladeTraversal.java
/** * This function traverses the reachables tree from the given start point using BFS, adds all the chemical's derivatives * to a file based on if they pass the mechanistic validator, and the derivatives' reaction pathway from the target * is also logged. Finally, for all the reactions that did not pass the mechanistic validator, we render those reactions * for furthur analysis into a directory. * * @param startPointId - The start point node id to traverse from * @param validatedInchisFileName - The file containing all the derivative inchis that pass the validator. * @param reactionPathwayFileName - The file containing the reaction pathway information from source to target. * @param renderedReactionDirName - The directory containing all the rendered chemical reactions that failed the * mechanistic validator. * @throws IOException//w ww . j av a2 s . c om */ private void traverseTreeFromStartPoint(Long startPointId, String validatedInchisFileName, String reactionPathwayFileName, String renderedReactionDirName) throws IOException { ReactionRenderer render = new ReactionRenderer(); PrintWriter validatedInchisWriter = new PrintWriter(validatedInchisFileName, "UTF-8"); PrintWriter reactionPathwayWriter = new PrintWriter(reactionPathwayFileName, "UTF-8"); LinkedList<Long> queue = new LinkedList<>(); queue.addAll(this.parentToChildren.get(startPointId)); while (!queue.isEmpty()) { Long candidateId = queue.pop(); validatedInchisWriter.println(db.readChemicalFromInKnowledgeGraph(candidateId).getInChI()); reactionPathwayWriter.println(formatPathFromSrcToDerivativeOfSrc(startPointId, candidateId)); Set<Long> children = this.parentToChildren.get(candidateId); if (children != null) { for (Long child : children) { for (Long rxnId : rxnIdsForEdge(candidateId, child)) { // In the case of a negative rxn id, this signifies the reaction is happening in reverse to what is // referenced in the DB. In order to get the correct db index, one has to transform this negative reaction // into its actual id. if (rxnId < 0) { rxnId = Reaction.reverseNegativeId(rxnId); } // Validate the reaction and only add its children to the queue if the reaction makes sense to our internal // ros and the child is not in the queue already. Map<Integer, List<Ero>> validatorResults = this.validator.validateOneReaction(rxnId); if (validatorResults != null && validatorResults.size() > 0 && !queue.contains(child)) { queue.add(child); } else { try { render.drawReaction(db.getReadDB(), rxnId, renderedReactionDirName, true); } catch (Exception e) { LOGGER.error( "Error caught when trying to draw and save reaction %d with error message: %s", rxnId, e.getMessage()); } } } } } } reactionPathwayWriter.close(); validatedInchisWriter.close(); }
From source file:org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.java
public static ScimGroup createOrUpdateGroup(RestTemplate client, String url, ScimGroup scimGroup) { //dont modify the actual argument LinkedList<ScimGroupMember> members = new LinkedList<>(scimGroup.getMembers()); ScimGroup existing = getGroup(client, url, scimGroup.getDisplayName()); if (existing != null) { members.addAll(existing.getMembers()); }// w w w . jav a 2s . c o m scimGroup.setMembers(members); if (existing != null) { scimGroup.setId(existing.getId()); client.put(url + "/Groups/{id}", scimGroup, scimGroup.getId()); return scimGroup; } else { ResponseEntity<String> group = client.postForEntity(url + "/Groups", scimGroup, String.class); if (group.getStatusCode() == HttpStatus.CREATED) { return JsonUtils.readValue(group.getBody(), ScimGroup.class); } else { throw new IllegalStateException("Invalid return code:" + group.getStatusCode()); } } }
From source file:net.erdfelt.android.sdkfido.configer.ConfigCmdLineParser.java
public void parse(String[] args) throws CmdLineParseException { LinkedList<String> arglist = new LinkedList<String>(); arglist.addAll(Arrays.asList(args)); // Quick Help if (arglist.contains("--" + OPT_HELP)) { usage();/*from www . jav a2s . c o m*/ return; } // Configuration File Option int idx = arglist.indexOf("--" + OPT_CONFIG); if (idx >= 0) { if (idx + 1 > arglist.size()) { throw new CmdLineParseException("Expected <File> parameter for option: --" + OPT_CONFIG); } String value = arglist.get(idx + 1); File file = (File) ConvertUtils.convert(value, File.class); this.configer.setPersistFile(file); arglist.remove(idx + 1); arglist.remove(idx); } // Save Options Option boolean saveOptions = false; idx = arglist.indexOf("--" + OPT_SAVE); if (idx >= 0) { saveOptions = true; arglist.remove(idx); } // Restore from persist first. try { configer.restore(); } catch (IOException e) { throw new CmdLineParseException("Unable to load configuration: " + e.getMessage(), e); } // Set values from command line now. String value; ListIterator<String> iter = arglist.listIterator(); while (iter.hasNext()) { String arg = iter.next(); if (arg.startsWith("--")) { // Its an option. String optname = arg.substring(2); Configurable cfgrbl = configer.getConfigurable(optname); if (cfgrbl == null) { throw new CmdLineParseException("Invalid Option: " + arg); } if (!iter.hasNext()) { throw new CmdLineParseException( "Expected <" + cfgrbl.getType() + "> parameter for option: " + arg); } value = iter.next(); configer.setValue(optname, value); continue; // process next arg } // All others are considered args. addToRawArgs(arg); } // Save options (if specified) if (saveOptions) { try { configer.persist(); } catch (IOException e) { throw new CmdLineParseException("Unable to save configuration: " + e.getMessage(), e); } } }
From source file:org.pf9.pangu.app.act.rest.diagram.services.ProcessInstanceHighlightsResource.java
/** * getHighLightedFlows/*from w ww . j a v a2 s. c o m*/ * * @param processDefinition * @param processInstanceId * @return */ private List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) { List<String> highLightedFlows = new ArrayList<String>(); List<HistoricActivityInstance> historicActivityInstances = historyService .createHistoricActivityInstanceQuery().processInstanceId(processInstanceId) //order by startime asc is not correct. use default order is correct. //.orderByHistoricActivityInstanceStartTime().asc()/*.orderByActivityId().asc()*/ .list(); LinkedList<HistoricActivityInstance> hisActInstList = new LinkedList<HistoricActivityInstance>(); hisActInstList.addAll(historicActivityInstances); getHighlightedFlows(processDefinition.getActivities(), hisActInstList, highLightedFlows); return highLightedFlows; }
From source file:org.apache.hadoop.hbase.replication.regionserver.DumpReplicationQueues.java
@Override public int run(String[] args) throws Exception { int errCode = -1; LinkedList<String> argv = new LinkedList<String>(); argv.addAll(Arrays.asList(args)); DumpOptions opts = parseOpts(argv);/*from www . j a v a 2 s. c o m*/ // args remaining, print help and exit if (!argv.isEmpty()) { errCode = 0; printUsage(); return errCode; } return dumpReplicationQueues(opts); }
From source file:acromusashi.stream.component.rabbitmq.AbstractContextBuilder.java
/** * ????????????RabbitMQ??/*from w ww .jav a 2 s. c om*/ * * @param contextList ? * @return RabbitMQ * @throws RabbitmqCommunicateException ?????????? */ protected Map<String, List<String>> initProcessLists(List<RabbitmqClusterContext> contextList) throws RabbitmqCommunicateException { if (this.contextMap == null) { this.contextMap = initContextMap(contextList); } Map<String, List<String>> processLists = new HashMap<String, List<String>>(); LinkedList<String> processList = null; String connectionProcess = null; int processIndex = 0; for (String queueName : this.contextMap.keySet()) { //??????? RabbitmqClusterContext context = this.contextMap.get(queueName); processList = new LinkedList<String>(context.getMqProcessList()); //RabbitMQ???????? //??(0) processIndex = 0; connectionProcess = context.getConnectionProcessMap().get(getClientId(queueName)); if (connectionProcess != null) { processIndex = processList.indexOf(connectionProcess); } //RabbitMQ?????RabbitMQ?? LinkedList<String> backwardProcesses = new LinkedList<String>(processList.subList(0, processIndex)); LinkedList<String> forwardProcesses = new LinkedList<String>( processList.subList(processIndex, processList.size())); forwardProcesses.addAll(backwardProcesses); processList = new LinkedList<String>(forwardProcesses); processLists.put(queueName, processList); } return processLists; }
From source file:org.guzz.api.taglib.GhostBoundaryTag.java
public List getBoundaryLimits() { LinkedList m_limits = new LinkedList(); if (inherit) { GhostBoundaryTag m_parent = getParentBoundary(); if (m_parent != null) { // m_limits.addAll(m_parent.getBoundaryLimits()); }// ww w. java 2 s . com } if (additionConditions != null) { m_limits.addAll(this.additionConditions); } return m_limits; }
From source file:cross.ObjectFactory.java
@Override public void configure(final Configuration cfg) { this.cfg = cfg; String[] contextLocations = null; if (this.cfg.containsKey(CONTEXT_LOCATION_KEY)) { log.debug("Using user-defined location: {}", (Object[]) this.cfg.getStringArray(CONTEXT_LOCATION_KEY)); contextLocations = cfg.getStringArray(CONTEXT_LOCATION_KEY); }//from w w w.j a va2 s .co m if (contextLocations == null) { log.debug("No pipeline configuration found! Please define! Example: -c cfg/pipelines/chroma.mpl"); return; } log.debug("Using context locations: {}", Arrays.toString(contextLocations)); try { if (cfg.containsKey("maltcms.home")) { File f = new File(new File(cfg.getString("maltcms.home")), "cfg/pipelines/xml/workflowDefaults.xml"); if (f.exists()) { log.info("Using workflow defaults at: {}", f); cfg.setProperty("cross.applicationContext.workflowDefaults", cfg.getString("cross.applicationContext.workflowDefaults.file")); } } else { log.info("Using workflow defaults from classpath."); } String[] defaultLocations = cfg.getStringArray("cross.applicationContext.defaultLocations"); log.debug("Using default context locations: {}", Arrays.toString(defaultLocations)); LinkedList<String> applicationContextLocations = new LinkedList<>(Arrays.asList(defaultLocations)); applicationContextLocations.addAll(Arrays.asList(contextLocations)); context = new DefaultApplicationContextFactory(applicationContextLocations, this.cfg) .createApplicationContext(); } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:eu.morfeoproject.fast.catalogue.planner.ScreenPlanner.java
/** * Creates a list of plans//from www.j a va 2 s . c om * @param goal * @param screens * @return list of plans */ public List<Plan> searchPlans(URI goal, List<Screen> screens) { LinkedList<URI> uriList = new LinkedList<URI>(); for (Screen screen : screens) { uriList.add(screen.getUri()); } LinkedList<Plan> planList = new LinkedList<Plan>(); List<Plan> searchList = searchPlans(goal); planList.addAll(rankList(searchList, uriList)); return reverse(removeDuplicates(planList, uriList)); }