List of usage examples for java.util ArrayList remove
public boolean remove(Object o)
From source file:com.lewisd.maven.lint.plugin.CheckMojo.java
protected String generateErrorMessage(List<String> outputReportList) throws MojoExecutionException { final StringBuffer message = new StringBuffer("[LINT] Violations found. "); if (outputReportList.isEmpty()) { message.append(//from www . ja v a 2 s. c o m "No output reports have been configured. Please see documentation regarding the outputReports configuration parameter."); } else { final boolean wroteSummaryToConsole; final ArrayList<String> remainingReports = new ArrayList<String>(outputReportList); if (outputReportList.contains("summary") && SummaryReportWriter.isConsole(summaryOutputFile)) { wroteSummaryToConsole = true; message.append("For more details, see error messages above"); remainingReports.remove("summary"); } else { wroteSummaryToConsole = false; message.append("For more details"); } if (remainingReports.isEmpty()) { message.append("."); } else { if (wroteSummaryToConsole) { message.append(", or "); } else { message.append(" see "); } message.append("results in "); if (remainingReports.size() == 1) { final File outputFile = getOutputFileForReport(remainingReports.get(0)); message.append(outputFile.getAbsolutePath()); } else { message.append("one of the following files: "); boolean first = true; for (final String report : remainingReports) { if (!first) { message.append(", "); } final File outputFile = getOutputFileForReport(report); message.append(outputFile.getAbsolutePath()); first = false; } } } } return message.toString(); }
From source file:io.s4.example.twittertopiccount.TopNTopicPE.java
public ArrayList<TopNEntry> getTopTopics() { if (entryCount < 1) return null; ArrayList<TopNEntry> sortedList = new ArrayList<TopNEntry>(); for (String key : topicMap.keySet()) { sortedList.add(new TopNEntry(key, topicMap.get(key))); }/*from w w w . j a va 2 s. c o m*/ Collections.sort(sortedList); // truncate: Yuck!! // unfortunately, Kryo cannot deserialize RandomAccessSubList // if we use ArrayList.subList(...) while (sortedList.size() > entryCount) sortedList.remove(sortedList.size() - 1); return sortedList; }
From source file:fr.openwide.talendalfresco.alfresco.NamePathServiceImpl.java
/** * Returns the namePath, starts below the company home ("Alfresco"). * Impl : could use a cache for better perfs, but Alfresco props are already cached (EHCache), * so for now it's ok like this./*ww w . j av a2 s . c om*/ * @param importNodeContext * @return null if null or non existing noderef */ public String getNamePath(NodeRef nodeRef, String pathDelimiter) { if (nodeRef == null || !nodeService.exists(nodeRef)) { return null; } java.util.ArrayList<String> pathNames = new java.util.ArrayList<String>(); for (NodeRef currentParentRef = nodeRef; currentParentRef != null; currentParentRef = nodeService .getPrimaryParent(currentParentRef).getParentRef()) { String parentName = (String) nodeService.getProperty(currentParentRef, ContentModel.PROP_NAME); pathNames.add(0, parentName); } pathNames.remove(0); // remove root node pathNames.remove(0); // remove company node "Alfresco" return pathDelimiter + StringUtils.collectionToDelimitedString(pathNames, pathDelimiter); }
From source file:no.met.jtimeseries.chart.Utility.java
/** * Removes time values closer than the specified interval (ensures that * dates are minHourInterval apart or more). * /*from w w w. j ava 2 s . c o m*/ * @param orig * Original date list * @param minHourInterval * The minimum interval hours * @param startPoint * Set the start point * @return The filtered date list */ public static List<Date> filterMinimumHourInterval(List<Date> orig, int minHourInterval, int startPoint) { if (orig.size() < 2) // nothing to filter return orig; ArrayList<Date> filtered = new ArrayList<Date>(); filtered.add(new Date(orig.get(startPoint).getTime())); long hourDiff; if (orig.size() >= 2) { Date prevDate = new Date(orig.get(startPoint).getTime()); for (int i = startPoint + 1; i < orig.size();) { hourDiff = ((orig.get(i).getTime() - prevDate.getTime()) / 3600000); // if hourdiff >= minHourInterval then add it directly if (hourDiff >= minHourInterval) { filtered.add(new Date(orig.get(i).getTime())); prevDate = new Date(orig.get(i).getTime()); i++; } else { while (hourDiff < minHourInterval && i < orig.size() - 1) { i++; hourDiff = ((orig.get(i).getTime() - prevDate.getTime()) / 3600000); } filtered.add(new Date(orig.get(i).getTime())); prevDate = new Date(orig.get(i).getTime()); i++; } } } filtered.remove(filtered.size() - 1); return filtered; }
From source file:edu.isi.wings.catalog.component.api.impl.kb.ComponentCreationKB.java
private ComponentTree createComponentHierarchy(String classid, boolean details) { ComponentHolder rootitem = new ComponentHolder(classid); ComponentTreeNode rootnode = new ComponentTreeNode(rootitem); ArrayList<ComponentTreeNode> queue = new ArrayList<ComponentTreeNode>(); queue.add(rootnode);// www . j a va 2 s .c om while (!queue.isEmpty()) { ComponentTreeNode node = queue.remove(0); ComponentHolder cls = node.getCls(); if (cls.getID() == null) continue; KBObject clsobj = kb.getConcept(cls.getID()); if (clsobj == null) continue; ArrayList<KBObject> compobjs = kb.getInstancesOfClass(clsobj, true); for (KBObject compobj : compobjs) { if (cls.getID().equals(this.topclass)) { // The top class cannot be used as a holder. If we find any // components having the top class as the holder, we delete them this.removeComponent(compobj.getID(), true, true); } else { // Add the component as the holder's component cls.setComponent(this.getComponent(compobj.getID(), details)); } } ArrayList<KBObject> subclasses = this.kb.getSubClasses(clsobj, true); for (KBObject subcls : subclasses) { if (!subcls.getNamespace().equals(this.pcdomns) && !subcls.getNamespace().equals(this.pcns)) continue; ComponentHolder clsitem = new ComponentHolder(subcls.getID()); ComponentTreeNode childnode = new ComponentTreeNode(clsitem); node.addChild(childnode); queue.add(childnode); } } ComponentTree tree = new ComponentTree(rootnode); return tree; }
From source file:br.fapesp.myutils.MyUtils.java
/** * Returns nsamples from values, chosen randomly _without_ replacement. * @param values/*from w ww .ja va 2s . c o m*/ * @param nsamples * @param rng optional random number generator * @param seed if no rng is passed, create one with this seed * @return */ public static double[] sampleWithoutReplacement(double[] values, int nsamples, Random rng, long seed) { if (nsamples > values.length) throw new RuntimeException("Requested sampling of more values than are available in array!"); Random r; if (rng == null) r = new Random(seed); else r = rng; double[] samples = new double[nsamples]; ArrayList<Double> al = new ArrayList<Double>(); for (int i = 0; i < values.length; i++) al.add(values[i]); for (int i = 0; i < nsamples; i++) samples[i] = al.remove(r.nextInt(al.size())); return samples; }
From source file:gov.usgs.anss.query.MSOutputer.java
public void makeFile(NSCL nscl, String filename, ArrayList<MiniSeed> blks) throws IOException { MiniSeed ms2 = null;/* ww w . ja va 2s. c o m*/ if (options.filemask.equals("%N")) { filename += ".ms"; } filename = filename.replaceAll("[__]", "_"); FileOutputStream out = FileUtils.openOutputStream(new File(filename)); if (!options.nosort) { Collections.sort(blks); } if (options.chkDups) { for (int i = blks.size() - 1; i > 0; i--) { if (blks.get(i).isDuplicate(blks.get(i - 1))) { blks.remove(i); } } } for (int i = 0; i < blks.size(); i++) { ms2 = (MiniSeed) blks.get(i); logger.fine("Out:" + ms2.getSeedName() + " " + ms2.getTimeString() + " ns=" + ms2.getNsamp() + " rt=" + ms2.getRate()); out.write(ms2.getBuf(), 0, ms2.getBlockSize()); } out.close(); }
From source file:br.fapesp.myutils.MyUtils.java
/** * Returns nsamples from values, chosen randomly _without_ replacement. * @param values/*from w w w. j av a2 s . c o m*/ * @param nsamples * @param rng optional random number generator * @param seed if no rng is passed, create one with this seed * @return */ public static int[] sampleWithoutReplacement(int[] values, int nsamples, Random rng, long seed) { if (nsamples > values.length) throw new RuntimeException("Requested sampling of more values than are available in array!"); Random r; if (rng == null) r = new Random(seed); else r = rng; int[] samples = new int[nsamples]; ArrayList<Integer> al = new ArrayList<Integer>(); for (int i = 0; i < values.length; i++) al.add(values[i]); for (int i = 0; i < nsamples; i++) samples[i] = al.remove(r.nextInt(al.size())); return samples; }
From source file:com.sillelien.dollar.api.types.DollarList.java
@NotNull @Override/*from w w w .j a v a 2s. com*/ public var $minus(@NotNull var rhs) { ArrayList<var> newVal = new ArrayList<>(list.mutable()); newVal.remove(rhs); return DollarFactory.fromValue(newVal, errors()); }
From source file:org.wikipedia.nirvana.nirvanabot.BotReporter.java
public void merge(List<ReportItem> data) { log.debug("Merge old data"); // 3 cases here: // 1) lists are equal (ideal) // 2) left has values that right has not // 3) right has values that left has not ArrayList<ReportItem> right = new ArrayList<ReportItem>(data); for (ReportItem r : reportItems) { for (int j = 0; j < right.size(); j++) { if (r.equals(right.get(j))) { ReportItem rMerge = right.get(j); r.merge(rMerge);/*from ww w .j a v a 2s .com*/ right.remove(j); break; } } } reportItems.addAll(right); }