Example usage for java.util TreeSet size

List of usage examples for java.util TreeSet size

Introduction

In this page you can find the example usage for java.util TreeSet size.

Prototype

public int size() 

Source Link

Document

Returns the number of elements in this set (its cardinality).

Usage

From source file:net.firejack.platform.generate.tools.Render.java

/**
 * @param params//from   w w  w  . j a  va 2s.  c o m
 * @return
 */
public String renderServiceParams(TreeSet<ServiceParam> params) {
    if (params == null || params.isEmpty())
        return "";
    StringBuilder builder = new StringBuilder();

    int i = 0;
    for (ServiceParam param : params) {
        builder.append(renderType(param));
        builder.append(" ").append(param.getName());
        if (i < params.size() - 1) {
            builder.append(", ");
        }
        i++;
    }
    return builder.toString();
}

From source file:org.mda.bcb.tcgagsdata.create.ProcessFile.java

protected void countBarcodesAndGenes(TreeMap<File, String> theFiles) throws FileNotFoundException, IOException {
    M_BARCODES = 0;//from  ww w.  j a  v a2s  .com
    M_GENES = 0;
    TreeSet<String> genes = new TreeSet<>();
    for (File file : theFiles.keySet()) {
        long start = System.currentTimeMillis();
        int numOfCol = 0;
        try (BufferedReader br = new BufferedReader(new FileReader(file))) {
            // header
            String line = br.readLine();
            numOfCol = line.split("\t", -1).length;
            while (null != (line = br.readLine())) {

                genes.add(line.substring(0, line.indexOf("\t")));
            }
        }
        M_BARCODES = M_BARCODES + numOfCol;
        long finish = System.currentTimeMillis();
        System.out.println("file " + ((finish - start) / 1000.0) + " seconds");
    }
    M_GENES = genes.size();
}

From source file:biz.netcentric.cq.tools.actool.dumpservice.impl.DumpserviceImpl.java

private void createTransientDumpNode(String dump, Node rootNode)
        throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException,
        VersionException, ConstraintViolationException, RepositoryException, ValueFormatException {

    NodeIterator nodeIt = rootNode.getNodes();

    // TreeSet used here since only this type offers the methods first() and
    // last()/*from  ww w  .  j a v  a 2s.c  o m*/
    TreeSet<Node> dumpNodes = new TreeSet<Node>(new JcrCreatedComparator());

    Node previousDumpNode = null;

    // get all dump nodes
    while (nodeIt.hasNext()) {
        Node currNode = nodeIt.nextNode();

        if (currNode.getName().startsWith(DUMP_NODE_PREFIX)) {
            dumpNodes.add(currNode);
        }
    }
    // try to get previous dump node
    if (!dumpNodes.isEmpty()) {
        previousDumpNode = dumpNodes.first();
    }
    // is limit of dump nodes to save reached?
    if (dumpNodes.size() > (nrOfSavedDumps - 1)) {
        Node oldestDumpNode = dumpNodes.last();
        oldestDumpNode.remove();
    }
    Node dumpNode = getNewDumpNode(dump, rootNode);

    // order the newest dump node as first child node of ac root node
    if (previousDumpNode != null) {
        rootNode.orderBefore(dumpNode.getName(), previousDumpNode.getName());
    }
}

From source file:com.houghtonassociates.bamboo.plugins.dao.GerritService.java

public GerritChangeVO getLastChange() throws RepositoryException {
    log.debug("getLastChange()...");

    Set<GerritChangeVO> changes = getGerritChangeInfo();

    TreeSet<GerritChangeVO> treeSet = new TreeSet<GerritChangeVO>(new SortByLastUpdate());
    treeSet.addAll(changes);//from   w  ww.j a v a 2s  .c o m

    if (treeSet.size() > 0)
        return treeSet.first();

    return null;
}

From source file:com.houghtonassociates.bamboo.plugins.dao.GerritService.java

public GerritChangeVO getLastChange(String project) throws RepositoryException {
    log.debug(String.format("getLastChange(project=%s)...", project));

    Set<GerritChangeVO> changes = getGerritChangeInfo(project);

    TreeSet<GerritChangeVO> treeSet = new TreeSet<GerritChangeVO>(new SortByLastUpdate());
    treeSet.addAll(changes);//from w w w.j  a v  a  2 s  .c  o m

    if (treeSet.size() > 0)
        return treeSet.first();

    return null;
}

From source file:com.houghtonassociates.bamboo.plugins.dao.GerritService.java

public GerritChangeVO getLastChange(String project, String branch) throws RepositoryException {
    log.debug(String.format("getLastChange(project=%s)...", project));

    Set<GerritChangeVO> changes = getGerritChangeInfo(project, branch);

    TreeSet<GerritChangeVO> treeSet = new TreeSet<GerritChangeVO>(new SortByLastUpdate());
    treeSet.addAll(changes);/*from ww w  .  j a v  a2  s  .co  m*/

    if (treeSet.size() > 0)
        return treeSet.first();

    return null;
}

From source file:com.houghtonassociates.bamboo.plugins.dao.GerritService.java

public GerritChangeVO getLastUnverifiedChange() throws RepositoryException {
    log.debug("getLastUnverifiedChange()...");

    Set<GerritChangeVO> changes = getGerritChangeInfo();

    TreeSet<GerritChangeVO> treeSet = new TreeSet<GerritChangeVO>(new SortByUnVerifiedLastUpdate());
    treeSet.addAll(changes);/*  www  .j  a v a 2s .  co m*/

    if ((treeSet.size() > 0) && (treeSet.first().getVerificationScore() == 0))
        return treeSet.first();

    return null;
}

From source file:com.houghtonassociates.bamboo.plugins.dao.GerritService.java

public GerritChangeVO getLastUnverifiedChange(String project) throws RepositoryException {
    log.debug(String.format("getLastUnverifiedChange(project=%s)...", project));

    Set<GerritChangeVO> changes = getGerritChangeInfo(project);

    TreeSet<GerritChangeVO> treeSet = new TreeSet<GerritChangeVO>(new SortByUnVerifiedLastUpdate());
    treeSet.addAll(changes);//from ww w .  j a  v  a 2s  .com

    if ((treeSet.size() > 0) && (treeSet.first().getVerificationScore() == 0))
        return treeSet.first();

    return null;
}

From source file:com.houghtonassociates.bamboo.plugins.dao.GerritService.java

public GerritChangeVO getLastUnverifiedChange(String project, String branch) throws RepositoryException {
    log.debug(String.format("getLastUnverifiedChange(project=%s)...", project));

    Set<GerritChangeVO> changes = getGerritChangeInfo(project, branch);

    TreeSet<GerritChangeVO> treeSet = new TreeSet<GerritChangeVO>(new SortByUnVerifiedLastUpdate());
    treeSet.addAll(changes);//from   www .j  av  a 2 s.  co  m

    if ((treeSet.size() > 0) && (treeSet.first().getVerificationScore() == 0))
        return treeSet.first();

    return null;
}

From source file:darks.learning.word2vec.Word2Vec.java

/**
 * Calculate specify word's nearest or relate words
 * //  ww  w . j a v  a  2  s. c  o m
 * @param word Specify word
 * @param topCount Result size
 * @return Nearest or relate words
 */
public Set<WordEntry> distance(String word, int topCount) {
    int resultSize = FastMath.min(topCount, wordNodes.size());
    TreeSet<WordEntry> result = new TreeSet<WordEntry>();
    WordNode node = wordNodes.get(word);
    if (node != null) {
        double minSim = Double.MIN_VALUE;
        for (WordNode target : wordNodes.values()) {
            if (target.name.equals(word)) {
                continue;
            }
            double sim = target.feature.dot(node.feature);
            if (sim > minSim) {
                result.add(new WordEntry(target.name, sim));
                if (result.size() > resultSize) {
                    result.pollLast();
                }
                minSim = result.last().similar;
            }
        }
    }
    return result;
}