Example usage for java.util TreeMap values

List of usage examples for java.util TreeMap values

Introduction

In this page you can find the example usage for java.util TreeMap values.

Prototype

public Collection<V> values() 

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:org.patientview.patientview.unitstat.UnitStatAction.java

private Collection<UnitMonthStats> turnUnitStatsListIntoRecords(List<UnitStat> unitStatsList,
        List<UnitStat> patientCountStatsList) {
    TreeMap<UnitStatId, UnitMonthStats> unitStatsRecords = new TreeMap<UnitStatId, UnitMonthStats>();
    addStatsToTree(unitStatsList, unitStatsRecords);
    addStatsToTree(patientCountStatsList, unitStatsRecords);
    return unitStatsRecords.values();
}

From source file:hivemall.anomaly.SingularSpectrumTransform.java

/**
 * Implicit Krylov Approximation (IKA) based naive scoring.
 *
 * Number of iterations for the Power method and QR method is fixed to 1 for efficiency. This
 * may cause failure (i.e. meaningless scores) depending on datasets and initial values.
 *
 *//*from w w  w .  j a  va2 s  .  c o m*/
private double computeScoreIKA(@Nonnull final RealMatrix H, @Nonnull final RealMatrix G) {
    // assuming n = m = window, and keep track the left singular vector as `q`
    MatrixUtils.power1(G, q, 1, q, new double[window]);

    RealMatrix T = new Array2DRowRealMatrix(k, k);
    MatrixUtils.lanczosTridiagonalization(H.multiply(H.transpose()), q, T);

    double[] eigvals = new double[k];
    RealMatrix eigvecs = new Array2DRowRealMatrix(k, k);
    MatrixUtils.tridiagonalEigen(T, 1, eigvals, eigvecs);

    // tridiagonalEigen() returns unordered eigenvalues,
    // so the top-r eigenvectors should be picked carefully
    TreeMap<Double, Integer> map = new TreeMap<Double, Integer>(Collections.reverseOrder());
    for (int i = 0; i < k; i++) {
        map.put(eigvals[i], i);
    }
    Iterator<Integer> indices = map.values().iterator();

    double s = 0.d;
    for (int i = 0; i < r; i++) {
        if (!indices.hasNext()) {
            throw new IllegalStateException("Should not happen");
        }
        double v = eigvecs.getEntry(0, indices.next().intValue());
        s += v * v;
    }
    return 1.d - Math.sqrt(s);
}

From source file:ru.runa.wfe.ss.cache.SubstitutionCacheImpl.java

public void onActorStatusChange(Actor actor, Change change) {
    log.debug("onActorStatusChange: " + actor);
    TreeMap<Substitution, HashSet<Long>> substitutions = actorToSubstitutorsCache.get(actor.getId());
    if (substitutions == null) {
        return;//from   w ww  .  j av  a2 s . co  m
    }
    for (HashSet<Long> substitutors : substitutions.values()) {
        if (substitutors != null) {
            for (Long substitutor : substitutors) {
                actorToSubstitutedCache.remove(substitutor);
            }
        }
    }
}

From source file:sadl.models.pdta.PDTA.java

public void toGraphvizFile(Path resultPath) throws IOException {
    try (BufferedWriter writer = Files.newBufferedWriter(resultPath, StandardCharsets.UTF_8)) {
        writer.write("digraph G {\n");

        // write states
        for (final PDTAState state : states.valueCollection()) {

            writer.write(Integer.toString(state.getId()));
            writer.write(" [shape=");

            if (state.isFinalState()) {
                writer.write("double");
            }//  ww w.j ava 2s.c  o  m

            writer.write("circle, label=\"" + Integer.toString(state.getId()) + "\"");
            writer.write("]\n");
        }

        for (final PDTAState state : states.valueCollection()) {
            for (final TreeMap<Double, PDTATransition> transitions : state.getTransitions().values()) {
                for (final PDTATransition transition : transitions.values()) {
                    writer.write(Integer.toString(state.getId()) + "->"
                            + Integer.toString(transition.getTarget().getId()) + " [label=<"
                            + transition.getEvent().getSymbol() + ">;];\n");
                }
            }
        }

        writer.write("}");
    }
}

From source file:api.wiki.WikiNameApi2.java

@Override
public void Search(PeopleNameOption option, ProgressCallback callback) {
    if (supports(option)) {
        String title = cultures.get(option.genre).replaceAll("\\s+", "_");
        TreeMap<String, String> values = getCategoryOption(title);

        if (containsGenderKey(values)) { // WE HAVE A GENDER KEY!
            for (String potentialGenderKey : values.values()) {
                if (option.gender == GenderOption.EITHER && (containeAnyKey(potentialGenderKey))) {
                    processAll(values.keySet(), option, callback);
                } else if (option.gender == GenderOption.AMBIGOUS && containsUniKey(potentialGenderKey)
                        || option.gender == GenderOption.FEMALE && containsFemaleKey(potentialGenderKey)
                        || option.gender == GenderOption.MALE && containsMaleKey(potentialGenderKey)) {
                    processSpecific(potentialGenderKey, option, callback);
                }//  w w  w .  java 2 s  . c o m
            }
        } else {
            System.out.println("preforming deep search");
        }
    }
}

From source file:com.cyclopsgroup.waterview.ui.view.system.status.SetLocale.java

/**
 * Overwrite or implement method execute()
 *
 * @see com.cyclopsgroup.waterview.Module#execute(com.cyclopsgroup.waterview.RuntimeData, com.cyclopsgroup.waterview.Context)
 *//*from   w w  w  . java  2  s  .  c o  m*/
public void execute(RuntimeData data, Context context) throws Exception {
    Locale[] locales = Locale.getAvailableLocales();
    TreeMap availableLocales = new TreeMap();
    for (int i = 0; i < locales.length; i++) {
        Locale locale = locales[i];
        if (StringUtils.isEmpty(locale.getCountry())) {
            continue;
        }
        String key = locale.getCountry() + '|' + locale.getLanguage();
        availableLocales.put(key, locale);
    }
    context.put("availableLocales", availableLocales.values());
    context.put("currentLocale", data.getSessionContext().get(RuntimeData.LOCALE_NAME));
}

From source file:jef.jre5support.Headers.java

public String toValueString() {
    TreeMap<String, String> m = new TreeMap<String, String>();
    for (String s : map.keySet()) {
        m.put(s, map.get(s).get(0));/*w  ww  .ja  v a 2 s. c o m*/
    }
    return StringUtils.join(m.values(), ",");
}

From source file:com.adobe.acs.commons.analysis.jcrchecksum.impl.JSONGenerator.java

/**
 * @param node//from www.  j  a  v  a 2 s.c om
 * @param opts
 * @param out
 * @throws RepositoryException
 * @throws IOException 
 * @throws JSONException
 */
private static void outputChildNodes(Node node, ChecksumGeneratorOptions opts, JsonWriter out)
        throws RepositoryException, IOException {
    Set<String> nodeTypeExcludes = opts.getExcludedNodeTypes();

    NodeIterator nodeIterator = node.getNodes();

    TreeMap<String, Node> childSortMap = new TreeMap<String, Node>();
    boolean hasOrderedChildren = false;
    try {
        hasOrderedChildren = node.getPrimaryNodeType().hasOrderableChildNodes();
    } catch (Exception expected) {
        // ignore
    }
    while (nodeIterator.hasNext()) {
        Node child = nodeIterator.nextNode();
        if (!nodeTypeExcludes.contains(child.getPrimaryNodeType().getName())) {
            if (hasOrderedChildren) {
                //output child node if parent is has orderable children
                out.name(child.getName());
                out.beginObject();
                generateSubnodeJSON(child, opts, out);
                out.endObject();
            } else {
                // otherwise put the child nodes into a sorted map
                // to output them with consistent ordering
                childSortMap.put(child.getName(), child);
            }
        }
    }
    // output the non-ordered child nodes in sorted order (lexicographically)
    for (Node child : childSortMap.values()) {
        out.name(child.getName());
        out.beginObject();
        generateSubnodeJSON(child, opts, out);
        out.endObject();
    }
}

From source file:cx.ring.model.Conversation.java

public Collection<TextMessage> getTextMessages(Date since) {
    TreeMap<Long, TextMessage> texts = new TreeMap<>();
    for (HistoryEntry h : history.values()) {
        texts.putAll(since == null ? h.getTextMessages() : h.getTextMessages(since.getTime()));
    }/*from   w ww  .  j a  v  a  2s .com*/
    return texts.values();
}

From source file:api.wiki.WikiNameApi2.java

private void processSpecific(String s, PeopleNameOption option, final ProgressCallback callback) {
    final TreeMap<String, String> values = getGenderNames(s);

    final float[] progressValues = ProgressUtil.getProgressValues(values.size());
    int counter = 1;

    for (final String peopleName : values.values()) {
        final int c = counter++;
        callback.onProgressUpdate(progressValues[c]);
        Task<Void> task = new Task<Void>() {
            @Override/*from  w  w  w.j  ava 2  s  .  c  o m*/
            protected Void call() throws Exception {
                final File file = processName(peopleName, option);
                Platform.runLater(new Runnable() {

                    @Override
                    public void run() {
                        callback.onProgress(processFile(peopleName, file));
                    }
                });

                return null;
            }
        };
        Thread thread = new Thread(task);
        thread.setPriority(Thread.MAX_PRIORITY);
        thread.start();
    }
}