Example usage for java.util List addAll

List of usage examples for java.util List addAll

Introduction

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

Prototype

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 (optional operation).

Usage

From source file:Main.java

/**
 * Returns the ordered keys of the given map
 * /*from  w  ww .j  a  v  a  2  s . c  om*/
 * @param map
 *            the map
 * @return the ordered keys
 */
public final static List<String> getOrderedKeys(final Map<String, Object> map) {
    List<String> keys = new LinkedList<String>();
    if (!map.isEmpty()) {
        keys.addAll(map.keySet());
        Collections.sort(keys, new Comparator<String>() {
            /**
             * {@inheritDoc}
             */
            public int compare(String o1, String o2) {
                if (o1 == o2) {
                    return 0;
                }
                int n1 = -1;
                int n2 = -1;
                try {
                    n1 = Integer.parseInt(o1.substring(1));
                } catch (NumberFormatException e) {
                    // IGNORE
                }
                try {
                    n2 = Integer.parseInt(o2.substring(1));
                } catch (NumberFormatException e) {
                    // IGNORE
                }
                /*
                 * n1 is a number
                 */
                if (n1 != -1) {
                    /*
                     * n2 is a number
                     */
                    if (n2 != -1) {
                        return n1 - n2;
                    }
                    /*
                     * n2 is a string literal
                     */
                    return -1;
                }
                /*
                 * n1 is a literal and n2 is a number
                 */
                if (n2 != -1) {
                    return -1;
                }
                /*
                 * both are literals
                 */
                return o1.compareTo(o2);
            }
        });
    }
    return keys;
}

From source file:org.onesun.atomator.adaptors.AdaptorFactory.java

public static List<String> getFeedURLs(String identity) {
    Set<String> set = urlEntries.get(identity);
    if (set != null) {
        List<String> list = new ArrayList<String>();
        list.addAll(set);

        return list;
    } else {/*from   w  w  w. ja va  2s. c o  m*/
        return null;
    }
}

From source file:com.intuit.tank.vm.common.util.ReportUtil.java

public static final String[] getSummaryHeaders() {
    List<String> l = new ArrayList<String>(SUMMARY_HEADERS.length + PERCENTILES.length);
    l.addAll(Arrays.asList(SUMMARY_HEADERS));
    for (int n = 0; n < PERCENTILES.length; n++) {
        l.add((String) PERCENTILES[n][0]);
    }//from w w w  .  j  av  a2 s.co  m
    return l.toArray(new String[l.size()]);
}

From source file:com.nortal.petit.orm.statement.clause.CompositeWherePart.java

public static CompositeWherePart of(LogicalOperation operation, SqlPart part, SqlPart... parts) {
    List<SqlPart> ps = new ArrayList<SqlPart>();
    ps.add(part);//from   w w  w  .ja v a  2  s .  c  om
    ps.addAll(Arrays.asList(parts));
    return new CompositeWherePart(operation, ps);
}

From source file:net.lldp.checksims.util.PairGenerator.java

/**
 * Generate all pairs for normal submissions, and pairs for archive submissions to compare to normal submissions.
 *
 * @param submissions Normal submissions - compared to each other and archive submissions
 * @param archiveSubmissions Archive submissions - only compared to normal submissions, not each other
 * @return Set of all unordered pairs required for comparison with archive directory
 *//*  ww w.  j  a  va  2  s . co m*/
public static Set<Pair<Submission, Submission>> generatePairsWithArchive(Set<Submission> submissions,
        Set<Submission> archiveSubmissions) {
    checkNotNull(submissions);
    checkNotNull(archiveSubmissions);

    // TODO it may be desirable to allow comparison of a single submission to an archive
    // However, generatePairs fails if only 1 submission is given
    // (This would also require tweaks in the frontend)
    Set<Pair<Submission, Submission>> basePairs = generatePairs(submissions);

    // If we have no archive submissions, just return the same result generatePairs would
    if (archiveSubmissions.isEmpty()) {
        return basePairs;
    }

    // Now we need to add pairs for the archive submissions
    List<Submission> remaining = new ArrayList<>();
    remaining.addAll(archiveSubmissions);

    // Loop through each archive submission
    while (!remaining.isEmpty()) {
        Submission first = remaining.get(0);
        remaining.remove(0);

        // For each archive submission, generate pairs for each normal submission
        for (Submission s : submissions) {
            Pair<Submission, Submission> pair = Pair.of(first, s);
            Pair<Submission, Submission> reversed = Pair.of(s, first);

            // Something's wrong, we've made a duplicate pair (but reversed)
            // Should never happen
            if (basePairs.contains(reversed)) {
                throw new RuntimeException("Internal error in pair generation: duplicate pair produced!");
            }

            // One pair for each normal submission, consisting of the archive submission and the normal submission
            basePairs.add(pair);
        }
    }

    return basePairs;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.externalServices.DomainObjectJSONSerializer.java

private static List<Slot> getAllSlots(DomainClass clazz) {
    final List<Slot> slots = new ArrayList<Slot>();
    if (clazz.hasSuperclass()) {
        slots.addAll(getAllSlots((DomainClass) clazz.getSuperclass()));
    }//  ww w  . j av  a2 s.  co m
    slots.addAll(clazz.getSlotsList());
    return slots;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.externalServices.DomainObjectJSONSerializer.java

private static List<Role> getAllRoleSlots(DomainClass clazz) {
    final List<Role> slots = new ArrayList<Role>();
    if (clazz.hasSuperclass()) {
        slots.addAll(getAllRoleSlots((DomainClass) clazz.getSuperclass()));
    }/*from w w w .j a v a2s  .c o m*/
    slots.addAll(clazz.getRoleSlotsList());
    return slots;
}

From source file:Main.java

public static <T> List<T> mergeLists(List<T> oldList, List<T> newList) {
    //TreeSet setBoth = new TreeSet(newList);
    HashSet<T> setBoth = new HashSet<>(newList);
    setBoth.addAll(oldList);/*from   www.  j  a v a 2 s. c  o m*/
    oldList.clear();
    oldList.addAll(setBoth);
    return oldList;
}

From source file:Main.java

public static List<Component> getAllComponents(final Container c) {
    Component[] comps = c.getComponents();
    List<Component> compList = new ArrayList<Component>();
    for (Component comp : comps) {
        compList.add(comp);/*from   ww  w  .  j a  v a  2s  . c o m*/
        if (comp instanceof Container)
            compList.addAll(getAllComponents((Container) comp));
    }
    return compList;
}

From source file:com.addthis.hydra.data.util.FindChangePoints.java

/**
 * Finds places where the data changed dramatically, either sustained or "instantaneously"
 *
 * @param data The array of integers in which to search
 * @return A list of pairs of integers of the form (index, size)
 *///from   w  w  w .  j  a  v a  2s . co m
public static List<ChangePoint> findSignificantPoints(Long[] data, int minChange, double minRatio,
        double minZScore, int inactiveThreshold, int windowSize) {
    List<ChangePoint> rv = new ArrayList<>();
    rv.addAll(findAndSmoothOverPeaks(data, minChange, minZScore, windowSize));
    rv.addAll(findChangePoints(data, minChange, minRatio, minZScore, inactiveThreshold, windowSize));
    return rv;
}