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.apache.flume.channel.file.FlumeEventQueue.java

/**
 * @return a copy of the set of fileIDs which are currently on the queue
 * will be normally be used when deciding which data files can
 * be deleted/*from  w w w. j  av a2  s . co m*/
 */
synchronized SortedSet<Integer> getFileIDs() {
    //Java implements clone pretty well. The main place this is used
    //in checkpointing and deleting old files, so best
    //to use a sorted set implementation.
    SortedSet<Integer> fileIDs = new TreeSet<Integer>(backingStore.getReferenceCounts());
    fileIDs.addAll(inflightPuts.getFileIDs());
    fileIDs.addAll(inflightTakes.getFileIDs());
    return fileIDs;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.administrativeOffice.lists.StudentsListByCurricularCourseDA.java

public ActionForward showActiveCurricularCourseScope(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws FenixActionException, FenixServiceException {

    final SearchStudentsByCurricularCourseParametersBean searchBean = getOrCreateSearchBean();

    final SortedSet<DegreeModuleScope> degreeModuleScopes = new TreeSet<DegreeModuleScope>(
            DegreeModuleScope.COMPARATOR_BY_CURRICULAR_YEAR_AND_SEMESTER_AND_CURRICULAR_COURSE_NAME_AND_BRANCH);
    degreeModuleScopes.addAll(
            searchBean.getDegreeCurricularPlan().getDegreeModuleScopesFor(searchBean.getExecutionYear()));

    if (degreeModuleScopes.isEmpty()) {
        addActionMessage("message", request, "error.nonExisting.AssociatedCurricularCourses");
    } else {/*from  w  ww  .j  a  va 2 s . c o m*/
        request.setAttribute("degreeModuleScopes", degreeModuleScopes);
    }

    request.setAttribute("searchBean", searchBean);
    return mapping.findForward("chooseCurricularCourse");
}

From source file:org.web4thejob.web.panel.base.AbstractCommandAwarePanel.java

@Override
public SortedSet<Command> getCommands() {
    if (commands != null) {
        SortedSet<Command> sortedSet = new TreeSet<Command>(COMMANDS_SORTER);
        sortedSet.addAll(commands.values());
        return Collections.unmodifiableSortedSet(sortedSet);
    } else {//ww  w .  j av a  2 s.c  o m
        return Command.EMPTY_COMMANDS_SET;
    }
}

From source file:net.sourceforge.fenixedu.domain.studentCurriculum.RootCurriculumGroup.java

public CycleCurriculumGroup getLastOrderedCycleCurriculumGroup() {
    final SortedSet<CycleCurriculumGroup> cycleCurriculumGroups = new TreeSet<CycleCurriculumGroup>(
            CycleCurriculumGroup.COMPARATOR_BY_CYCLE_TYPE_AND_ID);
    cycleCurriculumGroups.addAll(getInternalCycleCurriculumGroups());

    return cycleCurriculumGroups.isEmpty() ? null : cycleCurriculumGroups.last();
}

From source file:net.sourceforge.fenixedu.domain.mobility.outbound.OutboundMobilityCandidacyContestGroup.java

public SortedSet<ExecutionDegree> getSortedExecutionDegrees() {
    final SortedSet<ExecutionDegree> result = new TreeSet<ExecutionDegree>(
            ExecutionDegree.COMPARATOR_BY_DEGREE_CODE);
    result.addAll(getExecutionDegreeSet());
    return result;
}

From source file:org.apache.accumulo.shell.commands.DUCommand.java

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
        throws IOException, TableNotFoundException, NamespaceNotFoundException {

    final SortedSet<String> tables = new TreeSet<String>(Arrays.asList(cl.getArgs()));

    if (cl.hasOption(ShellOptions.tableOption)) {
        tables.add(cl.getOptionValue(ShellOptions.tableOption));
    }/*from w  ww .  jav a 2s.c om*/

    if (cl.hasOption(optNamespace.getOpt())) {
        Instance instance = shellState.getInstance();
        String namespaceId = Namespaces.getNamespaceId(instance, cl.getOptionValue(optNamespace.getOpt()));
        tables.addAll(Namespaces.getTableNames(instance, namespaceId));
    }

    boolean prettyPrint = cl.hasOption(optHumanReadble.getOpt()) ? true : false;

    // Add any patterns
    if (cl.hasOption(optTablePattern.getOpt())) {
        for (String table : shellState.getConnector().tableOperations().list()) {
            if (table.matches(cl.getOptionValue(optTablePattern.getOpt()))) {
                tables.add(table);
            }
        }
    }

    // If we didn't get any tables, and we have a table selected, add the current table
    if (tables.isEmpty() && !shellState.getTableName().isEmpty()) {
        tables.add(shellState.getTableName());
    }

    // sanity check...make sure the user-specified tables exist
    for (String tableName : tables) {
        if (!shellState.getConnector().tableOperations().exists(tableName)) {
            throw new TableNotFoundException(tableName, tableName, "specified table that doesn't exist");
        }
    }

    try {
        String valueFormat = prettyPrint ? "%9s" : "%,24d";
        for (DiskUsage usage : shellState.getConnector().tableOperations().getDiskUsage(tables)) {
            Object value = prettyPrint ? NumUtil.bigNumberForSize(usage.getUsage()) : usage.getUsage();
            shellState.getReader().println(String.format(valueFormat + " %s", value, usage.getTables()));
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    return 0;
}

From source file:spade.storage.CompressedTextFile.java

private static void updateAncestorsSuccessors(Map<Integer, Pair<SortedSet<Integer>, SortedSet<Integer>>> asl) {
    //for each line to update 
    Set<Map.Entry<Integer, Pair<SortedSet<Integer>, SortedSet<Integer>>>> entries = asl.entrySet();
    SortedSet<Integer> ancestors;
    SortedSet<Integer> successors;
    boolean updateAncestors;
    boolean updateSuccessors;
    HashMap<Integer, Pair<SortedSet<Integer>, SortedSet<Integer>>> toUpdate = new HashMap<Integer, Pair<SortedSet<Integer>, SortedSet<Integer>>>();
    //HashMap<Integer, Pair<SortedSet<Integer>, SortedSet<Integer>>> unchangedToUpdate = new HashMap<Integer, Pair<SortedSet<Integer>, SortedSet<Integer>>>();
    for (HashMap.Entry<Integer, Pair<SortedSet<Integer>, SortedSet<Integer>>> nodeToUpdate : entries) {
        Integer id = nodeToUpdate.getKey();
        Pair<Pair<Integer, SortedSet<Integer>>, Pair<Integer, SortedSet<Integer>>> lists = uncompressAncestorsSuccessorsWithLayer(
                id, true, true);/*from www .jav a 2 s . co m*/
        ancestors = lists.first().second();
        ancestors.addAll(nodeToUpdate.getValue().first());
        successors = lists.second().second();
        successors.addAll(nodeToUpdate.getValue().second());
        toUpdate.put(id, new Pair(ancestors, successors));

        //update other nodes but do not update the reference
        for (Integer nodeID = id + 1; nodeID < id + W + 1; nodeID++) {
            String line = get(scaffoldWriter, nodeID);
            if (line != null && line.contains("/")) {
                // get reference and see if it is id.
                String ancestorList = line.substring(line.indexOf(' ') + 1, line.indexOf("/") - 1);
                boolean isReferenceAncestor;
                if (ancestorList.contains("_")) {
                    isReferenceAncestor = false;
                } else {
                    Integer referenceAncestor = Integer
                            .parseInt(ancestorList.substring(0, ancestorList.indexOf(' ')));
                    isReferenceAncestor = id.equals(nodeID + referenceAncestor);
                }
                String successorList = line.substring(line.indexOf("/") + 2);
                successorList = successorList.substring(successorList.indexOf(' ') + 1);
                boolean isReferenceSuccessor;
                if (successorList.contains("_")) {
                    isReferenceSuccessor = false;
                } else {
                    Integer referenceSuccessor = Integer
                            .parseInt(successorList.substring(0, successorList.indexOf(' ')));
                    isReferenceSuccessor = id.equals(nodeID + referenceSuccessor);
                }
                if (isReferenceAncestor || isReferenceSuccessor) {
                    //update the encoding of the line
                    Pair<Pair<Integer, SortedSet<Integer>>, Pair<Integer, SortedSet<Integer>>> aux = uncompressAncestorsSuccessorsWithLayer(
                            nodeID, true, true);
                    if (!toUpdate.containsKey(nodeID))
                        toUpdate.put(nodeID, new Pair(aux.first().second(), aux.second().second()));
                }
            }
        }
    }
    Set<HashMap.Entry<Integer, Pair<SortedSet<Integer>, SortedSet<Integer>>>> entriesToUpdate = toUpdate
            .entrySet();
    for (HashMap.Entry<Integer, Pair<SortedSet<Integer>, SortedSet<Integer>>> nodeToUpdate : entriesToUpdate) {
        encodeAncestorsSuccessors(nodeToUpdate);
    }
}

From source file:net.sourceforge.fenixedu.domain.studentCurriculum.RootCurriculumGroup.java

public CycleCurriculumGroup getLastConcludedCycleCurriculumGroup() {
    final SortedSet<CycleCurriculumGroup> cycleCurriculumGroups = new TreeSet<CycleCurriculumGroup>(
            new ReverseComparator(CycleCurriculumGroup.COMPARATOR_BY_CYCLE_TYPE_AND_ID));
    cycleCurriculumGroups.addAll(getInternalCycleCurriculumGroups());

    for (final CycleCurriculumGroup curriculumGroup : cycleCurriculumGroups) {
        if (curriculumGroup.isConcluded()) {
            return curriculumGroup;
        }// w  ww . j a  va  2 s. c  o  m
    }

    return null;
}

From source file:org.apache.ctakes.ytex.libsvm.LibSVMGramMatrixExporterImpl.java

private double[][] loadGramMatrix(String name, String experiment, double param1, String param2,
        String splitName, String label, int run, int fold, InstanceData instanceData,
        SortedSet<Long> instanceIds, Map<Long, Integer> mapInstanceIdToIndex) {
    double[][] gramMatrix;
    instanceIds.clear();//from  w  ww . j  a v a 2 s .  com
    mapInstanceIdToIndex.clear();
    instanceIds.addAll(instanceData.getAllInstanceIds(label, run, fold));
    int index = 0;
    for (long instanceId : instanceIds) {
        mapInstanceIdToIndex.put(instanceId, index++);
    }
    gramMatrix = this.kernelUtil.loadGramMatrix(instanceIds, name, splitName, experiment, label, run, fold,
            param1, param2);
    return gramMatrix;
}

From source file:net.sourceforge.fenixedu.domain.credits.util.AnnualTeachingCreditsBean.java

public SortedSet<TeacherServiceLog> getLogs() {
    final SortedSet<TeacherServiceLog> logs = new TreeSet<TeacherServiceLog>();
    for (final AnnualTeachingCreditsByPeriodBean bean : annualTeachingCreditsByPeriodBeans) {
        logs.addAll(bean.getLogs());
    }/*w w w .jav a  2s  .  c om*/
    return logs;
}