Example usage for java.util ArrayList addAll

List of usage examples for java.util ArrayList addAll

Introduction

In this page you can find the example usage for java.util ArrayList addAll.

Prototype

public boolean addAll(Collection<? extends E> c) 

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator.

Usage

From source file:com.sillelien.dollar.api.types.DollarString.java

@NotNull
@Override/*from www  .  j  av a2s .  c o m*/
public var $plus(@NotNull var rhs) {
    final ImmutableList<Throwable> thisErrors = errors();
    final ArrayList<Throwable> errors = new ArrayList<>();
    errors.addAll(thisErrors.mutable());
    errors.addAll(rhs.errors().mutable());
    return DollarFactory.wrap(new DollarString(ImmutableList.copyOf(errors), value + rhs.toHumanString()));
}

From source file:fr.inria.oak.paxquery.algebra.operators.binary.BaseBinaryOperator.java

public ArrayList<NavigationTreePattern> getNavigationTreePatterns() {
    ArrayList<NavigationTreePattern> allNavigationTreePatterns = new ArrayList<NavigationTreePattern>(
            this.navigationTreePatternsLeft);
    allNavigationTreePatterns.addAll(this.navigationTreePatternsRight);
    return allNavigationTreePatterns;
}

From source file:FormatStorage1.IColumnDataFile.java

public void open(String fileName, ArrayList<Integer> idxs) throws IOException {
    this.columnprojects = new ArrayList<ArrayList<Integer>>();
    this.head = new IHead();
    this.readidxs = new TreeSet<Integer>();
    FileSystem fs = FileSystem.get(conf);
    FileStatus[] statuss = fs.globStatus(new Path(fileName + "_idx*"));
    this.cp2ifdfs.clear();
    this.idx2ifdfs.clear();
    if (idxs != null && idxs.size() > 0) {
        readidxs.addAll(idxs);/*from  w  w w  .  ja v a2 s.c o  m*/
        for (int i = 0; i < statuss.length; i++) {
            String file = statuss[i].getPath().toString();
            IFormatDataFile ifdf = null;
            String idxstr = file.substring(file.lastIndexOf("_idx") + 4);
            String[] sts = idxstr.split("_");
            TreeSet<Integer> ts = new TreeSet<Integer>();
            for (int j = 0; j < sts.length; j++) {
                ts.add(Integer.parseInt(sts[j]));
            }

            boolean contains = false;
            for (Integer id : idxs) {
                if (ts.contains(id)) {
                    contains = true;
                    if (ifdf == null) {
                        ifdf = new IFormatDataFile(conf);
                        ifdf.open(file);
                    }
                    this.idx2ifdfs.put(id, ifdf);
                }
            }
            if (contains) {
                ArrayList<Integer> cp = new ArrayList<Integer>();
                cp.addAll(ts);
                this.columnprojects.add(cp);
                this.cp2ifdfs.put(cp, ifdf);
            }
        }

    } else {
        for (int i = 0; i < statuss.length; i++) {
            String file = statuss[i].getPath().toString();
            IFormatDataFile ifdf = null;
            String idxstr = file.substring(file.lastIndexOf("_idx") + 4);
            String[] sts = idxstr.split("_");
            TreeSet<Integer> ts = new TreeSet<Integer>();
            ifdf = new IFormatDataFile(conf);
            ifdf.open(file);

            for (int j = 0; j < sts.length; j++) {
                int id = Integer.parseInt(sts[j]);
                ts.add(id);
                this.idx2ifdfs.put(id, ifdf);
            }

            ArrayList<Integer> cp = new ArrayList<Integer>();
            cp.addAll(ts);
            this.readidxs.addAll(ts);
            this.columnprojects.add(cp);
            this.cp2ifdfs.put(cp, ifdf);
        }
    }
    this.fieldtypes = new HashMap<Integer, IRecord.IFType>();
    for (Integer idx : this.readidxs) {
        this.fieldtypes.put(idx, this.idx2ifdfs.get(idx).fileInfo().head().fieldMap().fieldtypes().get(idx));
    }
    workstatus = ConstVar.WS_Read;
}

From source file:edu.msu.cme.rdp.classifier.train.validation.distance.PairwiseSeqDistance.java

public void printSummary(PrintStream outStream) {
    HashMap<String, ArrayList<Double>> rankDistanceMap = new HashMap<String, ArrayList<Double>>();
    outStream.println("\nrank\ttaxonname\ttotalcount\tmean_distance\tstdev");

    for (Taxonomy taxon : distanceMap.keySet()) {
        StdevCal.Std result = StdevCal.calStd(distanceMap.get(taxon));
        outStream.println(taxon.getHierLevel() + "\t" + taxon.getName() + "\t" + result.getTotalCount() + "\t"
                + String.format("%.3f", result.getMean()) + "\t" + String.format("%.3f", result.getStdev()));
        ArrayList<Double> distList = rankDistanceMap.get(taxon.getHierLevel());
        if (distList == null) {
            distList = new ArrayList<Double>();
            distList.addAll(distanceMap.get(taxon));
            rankDistanceMap.put(taxon.getHierLevel(), distList);
        } else {//w w w.j av a2  s.  co  m
            distList.addAll(distanceMap.get(taxon));
        }
    }

    outStream.println("\nrank\ttotalcount\tmean_distance\tstdev");
    for (String rank : rankDistanceMap.keySet()) {
        StdevCal.Std result = StdevCal.calStd(rankDistanceMap.get(rank));
        outStream.println(rank + "\t" + result.getTotalCount() + "\t" + String.format("%.3f", result.getMean())
                + "\t" + String.format("%.3f", result.getStdev()));

    }
    outStream.close();
}

From source file:logdruid.util.DataMiner.java

private static Map<Recording, String> getRegexp(Repository repo, Source source) {
    Map<Recording, String> recMatch = new HashMap<Recording, String>();
    Map<Recording, Boolean> activeRecordingOnSourceCache = new HashMap<Recording, Boolean>();
    ArrayList<Recording> recordings;
    recordings = repo.getRecordings(StatRecording.class);
    recordings.addAll(repo.getRecordings(EventRecording.class));
    StringBuffer sb = new StringBuffer(100);

    Iterator<Recording> recordingIterator = recordings.iterator();
    while (recordingIterator.hasNext()) {
        Recording rec = recordingIterator.next();
        if (!activeRecordingOnSourceCache.containsKey(rec)) {
            activeRecordingOnSourceCache.put(rec, source.isActiveRecordingOnSource(rec));
        }/*from   w  ww  .  j  a v  a 2  s  . c om*/
        if (activeRecordingOnSourceCache.get(rec)) {
            if (rec.getIsActive() == true) {
                ArrayList<RecordingItem> recordingItem = ((Recording) rec).getRecordingItem();
                Iterator<RecordingItem> recItemIte = recordingItem.iterator();
                if (logger.isDebugEnabled()) {
                    logger.debug("Record: " + rec.getName());
                }
                sb.setLength(0);
                int cnt = 0;
                while (recItemIte.hasNext()) {
                    RecordingItem recItem = recItemIte.next();
                    String stBefore = (String) recItem.getBefore();
                    String stType = (String) recItem.getType();
                    String stAfter = (String) recItem.getAfter();
                    if (stType.equals("date")) {
                        sb.append(stBefore);
                        sb.append("(");
                        sb.append(repo.getDateFormat(rec.getDateFormatID()).getPattern());
                        sb.append(")");
                        sb.append(stAfter);
                    } else {
                        sb.append(stBefore);
                        sb.append("(");
                        sb.append(getTypeString(stType));
                        sb.append(")");
                        sb.append(stAfter);
                    }
                }
                recMatch.put(rec, sb.toString());

                // logger.info("2**** regexp: "
                // +rec.getRegexp());
                if (logger.isDebugEnabled()) {
                    logger.debug("Pattern: " + sb.toString());
                }
            }
        }
    }
    return recMatch;
}

From source file:controller.VisLP.java

/**
 * @param  points/*from  w w  w.j  a va 2  s  .c o  m*/
 *         Unordered list of points that can form a
 *         convex polygon, but in the given order
 *         does not necessarily form a convex
 *         polygon if edges are drawn between the
 *         points in the given order.
 * @return 
 *         An ordered list of points that when edges
 *         are drawn in this order is guaranteed to
 *         form a convex polygon.
 */
static Point2D[] convex(Point2D[] points) {
    /* 
     * Sort the points first on x-value then
     * on y-value, both in ascending order.
     */
    Arrays.sort(points, new Comparator<Point2D>() {
        @Override
        public int compare(Point2D o1, Point2D o2) {
            double s = o1.getX() - o2.getX();
            if (s > 0)
                return 1;
            if (s < 0)
                return -1;

            s = o1.getY() - o2.getY();
            if (s > 0)
                return 1;
            if (s < 0)
                return -1;

            return 0;
        }
    });

    Point2D x_min = points[0];
    Point2D x_max = points[points.length - 1];

    ArrayList<Point2D> upper = new ArrayList<Point2D>();
    ArrayList<Point2D> lower = new ArrayList<Point2D>();

    upper.add(x_min);

    /* Find the slope of the line L connecting x_min and x_max */
    double mx = x_max.getX() - x_min.getX();
    double my = x_max.getY() - x_min.getY();
    double m = my / mx;

    /* Intersection of y-axis */
    double b = x_max.getY() - (m * x_max.getX());

    /* Add points above/below L to upper/lower, respectively */
    for (int i = 1; i < points.length - 1; i++) {
        Point2D p2d = points[i];
        double y = p2d.getX() * m + b;

        if (p2d.getY() >= y)
            upper.add(p2d);
        else
            lower.add(p2d);
    }

    /* Sort the lower list in descending order */
    lower.add(x_max);
    Collections.reverse(lower);

    upper.addAll(lower);
    return upper.toArray(new Point2D[0]);
}

From source file:it.unibas.spicy.persistence.xml.operators.UpdateDataSourceWithConstraints.java

private List<String> normalizeToList(String[] vector) {
    String currentPath;/*from   w w  w  . j  ava 2s.c  o  m*/
    ArrayList<String> listPaths = new ArrayList<String>();
    for (int i = 0; i < vector.length; i++) {
        currentPath = vector[i];
        listPaths.addAll(normalizePath(currentPath));
    }
    return listPaths;
}

From source file:com.perl5.lang.perl.util.PerlPackageUtil.java

@NotNull
public static List<PerlNamespaceDefinition> collectNamespaceDefinitions(@NotNull Project project,
        @NotNull List<String> packageNames) {
    ArrayList<PerlNamespaceDefinition> namespaceDefinitions = new ArrayList<PerlNamespaceDefinition>();
    for (String packageName : packageNames) {
        Collection<PerlNamespaceDefinition> list = getNamespaceDefinitions(project, packageName,
                GlobalSearchScope.projectScope(project));

        if (list.isEmpty()) {
            list = getNamespaceDefinitions(project, packageName,
                    PerlScopes.getProjectAndLibrariesScope(project));
        }//from  w  w w .j a  v a2s.  co m

        namespaceDefinitions.addAll(list);
    }
    return namespaceDefinitions;
}

From source file:com.clustercontrol.jobmanagement.util.JobValidator.java

private static ArrayList<String> getJobIdList(JobTreeItem item) {
    if (item == null || item.getData() == null) {
        return new ArrayList<String>();
    }/*  www. j av  a 2s  .  com*/
    ArrayList<String> ret = new ArrayList<String>();
    ret.add(item.getData().getId());
    for (JobTreeItem child : item.getChildren()) {
        ret.addAll(getJobIdList(child));
    }
    return ret;
}