Example usage for java.util SortedSet addAll

List of usage examples for java.util SortedSet addAll

Introduction

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

Prototype

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

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:org.jenkins.ci.plugins.jobimport.RemoteJobUtils.java

public static SortedSet<RemoteJob> fromXml(final String xml)
        throws XPathExpressionException, SAXException, IOException, ParserConfigurationException {
    final SortedSet<RemoteJob> remoteJobs = new TreeSet<RemoteJob>();

    if (StringUtils.isEmpty(xml)) {
        return remoteJobs;
    }/*from   ww  w  . ja v a2  s  . c o m*/

    // ---

    if (xml.startsWith("<hudson>")) {
        remoteJobs.addAll(fromHudsonXml(xml));
    }

    else if (xml.startsWith("<freeStyleProject>")) {
        remoteJobs.add(fromFreeStyleProjectXml(xml));
    }

    else if (xml.startsWith("<listView>")) {
        remoteJobs.addAll(fromListViewXml(xml));
    }

    else if (xml.startsWith("<mavenModuleSet>")) {
        remoteJobs.add(fromMavenModuleSetXml(xml));
    }

    else if (xml.startsWith("<matrixProject>")) {
        remoteJobs.add(fromMatrixProjectXml(xml));
    }

    return remoteJobs;
}

From source file:com.spotify.heroic.filter.impl.OrFilterImpl.java

private static SortedSet<Filter> flatten(final Collection<Filter> statements) {
    final SortedSet<Filter> result = new TreeSet<>();

    for (final Filter f : statements) {
        final Filter o = f.optimize();

        if (o == null) {
            continue;
        }/*from   w  ww  . j a va 2s  .c o m*/

        if (o instanceof Filter.Or) {
            result.addAll(((Filter.Or) o).terms());
            continue;
        }

        if (o instanceof Filter.Not) {
            final Filter.Not not = (Filter.Not) o;

            if (not.first() instanceof Filter.And) {
                result.addAll(collapseNotAnd((Filter.And) not.first()));
                continue;
            }
        }

        result.add(o);
    }

    return result;
}

From source file:de.uni_potsdam.hpi.asg.logictool.helper.BDDHelper.java

public static BDD mergeBDDs(BDD bdd, NetlistVariable replaceVar, BDD replaceBdd, Netlist netlist) {

    Set<NetlistVariable> bddvars = BDDHelper.getVars(bdd, netlist);
    if (!bddvars.contains(replaceVar)) {
        logger.error("ReplaceVar not in Vars");
        return null;
    }/* w w  w. j  av  a2s  . co  m*/

    if (bddvars.size() == 1) {
        //         logger.debug("Shortcut");
        //         logger.debug("BDD: " + getFunctionString(bdd, netlist));
        //         logger.debug("ReplBDD: " + getFunctionString(replaceBdd, netlist));
        //         logger.debug("ReplVar: " + replaceVar.getName());
        if (isPos(bdd, replaceVar)) {
            return replaceBdd;
        } else {
            return replaceBdd.not();
        }
        //         return replaceBdd;//.and(netlist.getFac().one());
    }

    SortedSet<NetlistVariable> newinputs = new TreeSet<>();
    newinputs.addAll(bddvars);
    newinputs.addAll(BDDHelper.getVars(replaceBdd, netlist));
    newinputs.remove(replaceVar);
    //      System.out.println("New Inp: " + newinputs.toString());

    BDD retVal = netlist.getFac().zero();
    BitSet b = new BitSet(newinputs.size());
    for (int i = 0; i < Math.pow(2, newinputs.size()); i++) {
        //         System.out.println(i + ": " + BitSetHelper.formatBitset(b, newinputs.size()));
        int index = 0;
        BDD bdd_new = bdd;
        BDD replacBdd_new = replaceBdd;
        BDD minterm = netlist.getFac().one();
        //TODO: xWITH
        for (NetlistVariable var : newinputs) {
            if (b.get(index)) {
                bdd_new = bdd_new.restrict(var.toBDD());
                replacBdd_new = replacBdd_new.restrict(var.toBDD());
                minterm = minterm.and(var.toBDD());
            } else {
                bdd_new = bdd_new.restrict(var.toNotBDD());
                replacBdd_new = replacBdd_new.restrict(var.toNotBDD());
                minterm = minterm.and(var.toNotBDD());
            }
            index++;
        }
        if (replacBdd_new.isZero()) {
            bdd_new = bdd_new.restrict(replaceVar.toNotBDD());
        } else if (replacBdd_new.isOne()) {
            bdd_new = bdd_new.restrict(replaceVar.toBDD());
        } else {
            logger.error("Repl BDD should be one or zero");
        }

        if (bdd_new.isZero()) {

        } else if (bdd_new.isOne()) {
            retVal.orWith(minterm);
        } else {
            logger.error("BDD should be one or zero");
        }

        BitSetHelper.dualNext(b);
    }

    //      if(bddvars.size() == 1) {
    //         logger.debug("RetVal: " + getFunctionString(retVal, netlist));
    //      }

    return retVal;
}

From source file:io.hops.experiments.results.compiler.RawBMResultAggregator.java

private static void lines(CompiledResults hdfsCr, CompiledResults hopsFsCr, String outputFolder)
        throws IOException {
    //  linear graph
    String outputFile = outputFolder + "/lines.txt";
    String allData = "";
    String header = CompileResults.format("NameNodes:");
    for (Integer i : hopsFsCr.nnCounts) {
        header += CompileResults.format(i + "-NN");
    }//from w  ww . j  a  va 2  s  .co m
    header += "\n";
    allData += header;

    SortedSet<BenchmarkOperations> sorted = new TreeSet<BenchmarkOperations>();
    sorted.addAll(hopsFsCr.valsMap.keySet());
    for (BenchmarkOperations op : sorted) {
        List<Double> hopsVals = hopsFsCr.valsMap.get(op);
        String msg = CompileResults.format("HopsFS_" + op.toString());
        for (Double val : hopsVals) {
            msg += CompileResults.format(DFSOperationsUtils.round(val) + "");
        }

        msg += "\n" + CompileResults.format("HDFS_" + op.toString());

        List<Double> hdfsVals = hdfsCr.valsMap.get(op);
        int hdfsRecordSize = 0;
        if (hdfsVals != null) {
            if (hdfsVals.size() > 1) {
                System.err.println("In Hdfs there should be only one value for " + op);
                System.exit(0);
            }

            if (hdfsVals.size() == 1) {
                msg += CompileResults.format(hdfsVals.get(0) + "");
            } else {
                msg += CompileResults.format(RECORD_NOT_FOUND);
            }
            hdfsRecordSize = 1;
        }

        for (int i = 0; i < hopsFsCr.nnCounts.size() - hdfsRecordSize; i++) {
            msg += CompileResults.format(RECORD_NOT_FOUND);
        }

        msg += "\n";
        allData += msg;
    }
    System.out.println(allData);
    CompileResults.writeToFile(outputFile, allData, false);

}

From source file:de.tudarmstadt.ukp.dkpro.tc.svmhmm.util.SVMHMMUtils.java

/**
 * Extract all outcomes from featureVectorsFiles (training, test) that are in
 * LIBSVM format - each line is a feature vector and the first token is the outcome
 * label/*from   w  w w . j a  v  a 2s . c om*/
 *
 * @param files files in LIBSVM format
 * @return set of all unique outcomes
 * @throws java.io.IOException
 */
public static SortedSet<String> extractOutcomeLabelsFromFeatureVectorFiles(File... files) throws IOException {
    SortedSet<String> result = new TreeSet<>();

    for (File file : files) {
        result.addAll(extractOutcomeLabels(file));
    }

    return result;
}

From source file:pt.ist.fenixedu.teacher.domain.teacher.TeacherService.java

public static SortedSet<SupportLesson> getSupportLessonsOrderedByStartTimeAndWeekDay(
        Professorship professorship) {//  www. j  a va2s .c  o  m
    final SortedSet<SupportLesson> supportLessons = new TreeSet<SupportLesson>(
            SupportLesson.SUPPORT_LESSON_COMPARATOR_BY_HOURS_AND_WEEK_DAY);
    supportLessons.addAll(professorship.getSupportLessonsSet());
    return supportLessons;
}

From source file:io.hops.experiments.results.compiler.RawBMResultAggregator.java

private static void histogram(CompiledResults hdfsCr, CompiledResults hopsFsCr, String outputFolder)
        throws IOException {

    String header = CompileResults.format("NameNodes");
    header += CompileResults.format("SingleNN");
    for (Integer i : hopsFsCr.nnCounts) {
        header += CompileResults.format(i + "-NN");
    }// w  w w.ja v a2s . c om

    boolean isFirstRecord = true;
    String col = "t col";

    //TODO use String buffer everywhere
    String allData = "";
    String plotCommands = "";

    SortedSet<BenchmarkOperations> sorted = new TreeSet<BenchmarkOperations>();
    sorted.addAll(hopsFsCr.valsMap.keySet());
    for (BenchmarkOperations op : sorted) {
        int colorIndex = 0;
        List<Double> hopsHisto = hopsFsCr.histoMap.get(op);
        String msg = CompileResults.format("#" + op) + "\n";
        msg += header + "\n";
        msg += CompileResults.format("HopsFS");
        msg += CompileResults.format(RECORD_NOT_FOUND); // first col 
        for (Double val : hopsHisto) {
            msg += CompileResults.format(DFSOperationsUtils.round(val) + "");
        }

        msg += "\n";
        msg += CompileResults.format("HDFS");
        List<Double> hdfsVals = hdfsCr.valsMap.get(op);
        if (hdfsVals != null) {
            if (hdfsVals.size() > 1) {
                System.err.println("In Hdfs there should be only one value for " + op);
                System.exit(0);
            }

            if (hdfsVals.size() == 1) {
                msg += CompileResults.format(hdfsVals.get(0) + "");
            }
        } else {
            msg += CompileResults.format(0 + "");
        }

        for (int i = 0; i < hopsFsCr.nnCounts.size(); i++) {
            msg += CompileResults.format(RECORD_NOT_FOUND);
        }
        msg += "\n";

        allData += msg;

        System.out.println(msg);
        CompileResults.writeToFile(outputFolder + "/" + op + ".dat", msg, false);

        String plotCommand = "";
        if (isFirstRecord) {
            plotCommand += "plot ";
        }

        plotCommand += " newhistogram \"" + op.toString().replace("_", "\\n") + "\", ";
        plotCommand += "\'" + op + ".dat\' ";
        plotCommand += " using \"SingleNN\":xtic(1) not  lc rgb '#d73027', ";
        for (Integer i : hopsFsCr.nnCounts) {
            plotCommand += "'' u \"" + i + "-NN\" " + col + getColor(colorIndex++) + " , ";
        }
        plotCommand += "\\\n";

        if (isFirstRecord) {
            isFirstRecord = false;
            col = "not";
        }

        plotCommands += plotCommand;

    }
    System.out.println(plotCommands);
    CompileResults.writeToFile(outputFolder + "/histo-internal.gnuplot", plotCommands, false);
    System.out.println(allData);
    CompileResults.writeToFile(outputFolder + "/histogram-all-data.dat", allData, false);
}

From source file:pt.ist.fenixedu.teacher.domain.teacher.TeacherService.java

public static SortedSet<DegreeTeachingService> getDegreeTeachingServicesOrderedByShift(
        Professorship professorship) {/* w  ww.ja  v a  2 s .  c om*/
    final SortedSet<DegreeTeachingService> degreeTeachingServices = new TreeSet<DegreeTeachingService>(
            DegreeTeachingService.DEGREE_TEACHING_SERVICE_COMPARATOR_BY_SHIFT);
    degreeTeachingServices.addAll(professorship.getDegreeTeachingServicesSet());

    return degreeTeachingServices;
}

From source file:com.spotify.heroic.filter.impl.AndFilterImpl.java

private static SortedSet<Filter> flatten(final Collection<Filter> statements) {
    final SortedSet<Filter> result = new TreeSet<>();

    for (final Filter f : statements) {
        final Filter o = f.optimize();

        if (o == null) {
            continue;
        }//from   w w w  .  ja v  a2s  .  c  o  m

        if (o instanceof Filter.And) {
            result.addAll(((Filter.And) o).terms());
            continue;
        }

        if (o instanceof Filter.Not) {
            final Filter.Not not = (Filter.Not) o;

            if (not.first() instanceof Filter.Or) {
                result.addAll(collapseNotOr((Filter.Or) not.first()));
                continue;
            }
        }

        result.add(o);
    }

    return result;
}

From source file:com.asakusafw.runtime.stage.input.StageInputDriver.java

private static String[] buildDictionary(List<StageInput> inputList) {
    assert inputList != null;
    SortedSet<String> values = new TreeSet<>();
    for (StageInput input : inputList) {
        values.add(input.getPathString());
        values.add(input.getFormatClass().getName());
        values.add(input.getMapperClass().getName());
        values.addAll(input.getAttributes().keySet());
        values.addAll(input.getAttributes().values());
    }// ww  w .  j  av a  2 s  .  co m
    return values.toArray(new String[values.size()]);
}