List of usage examples for java.util LinkedList add
public boolean add(E e)
From source file:com.cloud.agent.resource.virtualnetwork.ConfigHelper.java
private static List<ConfigItem> generateConfig(SetPortForwardingRulesVpcCommand cmd) { LinkedList<ConfigItem> cfg = new LinkedList<>(); for (PortForwardingRuleTO rule : cmd.getRules()) { String args = rule.revoked() ? "-D" : "-A"; args += " -P " + rule.getProtocol().toLowerCase(); args += " -l " + rule.getSrcIp(); args += " -p " + rule.getStringSrcPortRange(); args += " -r " + rule.getDstIp(); args += " -d " + rule.getStringDstPortRange().replace(":", "-"); cfg.add(new ScriptConfigItem(VRScripts.VPC_PORTFORWARDING, args)); }//w w w. j av a 2s . c om return cfg; }
From source file:lv.semti.morphology.webservice.TokenResource.java
private String analyze(String query) { List<Word> tokens = Splitting.tokenize(MorphoServer.analyzer, query); LinkedList<String> tokenJSON = new LinkedList<String>(); for (Word word : tokens) { tokenJSON.add(word.toJSONsingle()); }/*w w w . jav a2 s.co m*/ return formatJSON(tokenJSON); }
From source file:io.fabric8.spring.cloud.kubernetes.reload.ConfigurationChangeDetector.java
private <E> LinkedList<E> toLinkedList(Iterable<E> it) { LinkedList<E> list = new LinkedList<E>(); for (E e : it) { list.add(e); }//from w w w .ja v a2 s. c o m return list; }
From source file:com.offbynull.voip.audio.gateways.io.OutputWriteRunnable.java
private LinkedList<OutputData> dumpQueue() throws InterruptedException { LinkedList<OutputData> ret = new LinkedList<>(); OutputData first = outputQueue.take(); ret.add(first); outputQueue.drainTo(ret);/*from w w w.ja va 2 s.c o m*/ return ret; }
From source file:com.heliosdecompiler.helios.tasks.AddFilesTask.java
private void handleDirectory(File file) throws IOException { LinkedList<File> filesToProcess = new LinkedList<>(); filesToProcess.add(file); Set<String> filesProcessed = new HashSet<>(); while (!filesToProcess.isEmpty()) { File current = filesToProcess.pop(); if (current.isFile() && filesProcessed.add(current.getCanonicalPath())) { handle(current);// w w w . ja v a 2s . co m } else { File[] listFiles = current.listFiles(); if (listFiles != null) { filesToProcess.addAll(Arrays.asList(listFiles)); } } } }
From source file:net.semanticmetadata.lire.utils.FileUtils.java
public static void saveImageResultsToPng(String prefix, TopDocs hits, String queryImage, IndexReader ir) throws IOException { LinkedList<BufferedImage> results = new LinkedList<BufferedImage>(); int width = 0; for (int i = 0; i < Math.min(hits.scoreDocs.length, 10); i++) { // hits.score(i) // hits.doc(i).get("descriptorImageIdentifier") BufferedImage tmp = ImageIO .read(new FileInputStream(ir.document(hits.scoreDocs[i].doc).get("descriptorImageIdentifier"))); if (tmp.getHeight() > 200) { double factor = 200d / ((double) tmp.getHeight()); tmp = ImageUtils.scaleImage(tmp, (int) (tmp.getWidth() * factor), 200); }//from w ww .jav a 2s.c o m width += tmp.getWidth() + 5; results.add(tmp); } BufferedImage result = new BufferedImage(width, 220, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = (Graphics2D) result.getGraphics(); g2.setColor(Color.black); g2.clearRect(0, 0, result.getWidth(), result.getHeight()); g2.setColor(Color.green); g2.setFont(Font.decode("\"Arial\", Font.BOLD, 12")); int offset = 0; int count = 0; for (Iterator<BufferedImage> iterator = results.iterator(); iterator.hasNext();) { BufferedImage next = iterator.next(); g2.drawImage(next, offset, 20, null); g2.drawString(hits.scoreDocs[count].score + "", offset + 5, 12); offset += next.getWidth() + 5; count++; } ImageIO.write(result, "PNG", new File(prefix + "_" + (System.currentTimeMillis() / 1000) + ".png")); }
From source file:mitm.common.dlp.impl.PolicyViolationImplTest.java
@Test public void testSerializeCollection() { LinkedList<PolicyViolation> violations = new LinkedList<PolicyViolation>(); violations.add(new PolicyViolationImpl("built in", "The message could not be encrypted", null, PolicyViolationPriority.QUARANTINE)); System.out.println(Base64Utils.encodeChunked(SerializationUtils.serialize(violations))); }
From source file:com.marklogic.contentpump.utilities.FileIterator.java
public FileIterator(FileSplit inSplit, TaskAttemptContext context) { conf = context.getConfiguration();// w w w. j a va 2s .c o m fileDirSplits = new LinkedList<FileSplit>(); LinkedList<FileSplit> src = new LinkedList<FileSplit>(); src.add(inSplit); iterator = src.iterator(); PathFilter jobFilter = getInputPathFilter(); List<PathFilter> filters = new ArrayList<PathFilter>(); filters.add(FileAndDirectoryInputFormat.hiddenFileFilter); if (jobFilter != null) { filters.add(jobFilter); } inputFilter = new FileAndDirectoryInputFormat.MultiPathFilter(filters); }
From source file:com.rapidminer.operator.learner.functions.linear.TTestLinearRegressionMethod.java
@Override public List<ParameterType> getParameterTypes() { LinkedList<ParameterType> types = new LinkedList<ParameterType>(); types.add(new ParameterTypeDouble(PARAMETER_SIGNIFICANCE_LEVEL, "This is the significance level of the t-test.", 0, 1, 0.05)); return types; }
From source file:com.hp.alm.ali.idea.progress.IndicatingOutputStreamTest.java
@Test public void testReporting() throws IOException { final LinkedList<Double> fractions = new LinkedList<Double>(); fractions.add(0.25); fractions.add(0.75);//ww w . j a va 2 s.c o m fractions.add(0.80); fractions.add(1.0); handler.async(4); IndicatingOutputStream ios = new IndicatingOutputStream(file, 20, new ProgressIndicatorBase() { @Override public void setFraction(final double fraction) { handler.done(new Runnable() { @Override public void run() { Assert.assertEquals(fractions.removeFirst(), (Double) fraction); } }); } }); byte[] buf0 = "1234\n".getBytes(); byte[] buf1 = "123456789\n".getBytes(); byte[] buf2 = "678\n".getBytes(); ios.write(buf0); ios.write(buf1); ios.write('5'); ios.write(buf2); ios.close(); Assert.assertEquals("1234\n123456789\n5678\n", FileUtils.readFileToString(file)); }