List of usage examples for java.util TreeSet descendingSet
public NavigableSet<E> descendingSet()
From source file:pltag.parser.params.ProbVec.java
private Set<Pair<Integer>> getSorted(double[] counts) { int length = counts.length; TreeSet<Pair<Integer>> pairs = new TreeSet<Pair<Integer>>(); // sort automatically by probability (pair.value) for (int i = 0; i < length; i++) { pairs.add(new Pair(counts[i], new Integer(i))); }//from ww w . j a va 2 s . co m return pairs.descendingSet(); }
From source file:pltag.parser.params.SparseVec.java
@Override public Set<Pair<Integer>> getProbsSorted() { TreeSet<Pair<Integer>> pairs = new TreeSet<Pair<Integer>>(); // sort automatically by probability (pair.value) for (int i = 0; i < size(); i++) { pairs.add(new Pair(counts.getEntry(i) / sum, new Integer(i))); }/*from w w w . java 2 s. c o m*/ return pairs.descendingSet(); }
From source file:pltag.parser.params.SparseVec.java
@Override public Set<Pair<Integer>> getCountsSorted() { TreeSet<Pair<Integer>> pairs = new TreeSet<Pair<Integer>>(); // sort automatically by probability (pair.value) for (int i = 0; i < size(); i++) { // in the discriminative model we save weights not probabilities, so no need to normalise pairs.add(new Pair(counts.getEntry(i), new Integer(i))); }//from w ww. j av a 2s. c o m return pairs.descendingSet(); }
From source file:ubic.gemma.web.controller.common.HomePageController.java
/** * For the show-off graph that shows number of data sets per taxon. *//*from w w w. j av a2 s . com*/ public void getCountsForTaxonPieChart() { Map<Taxon, Long> unsortedEEsPerTaxon = expressionExperimentService.getPerTaxonCount(); /* * Sort taxa by count. */ TreeSet<Map.Entry<Taxon, Long>> eesPerTaxonValueSorted = new TreeSet<Map.Entry<Taxon, Long>>( new TaxonComparator()); eesPerTaxonValueSorted.addAll(unsortedEEsPerTaxon.entrySet()); long expressionExperimentCount = expressionExperimentService.countAll(); double groupBelow = 0.1; // if a taxon has less then this percent of total count, group into 'other' String googleData = encodeDataForGoogle(eesPerTaxonValueSorted.descendingSet(), expressionExperimentCount, groupBelow); List<String> googleLabelsColls = new ArrayList<String>(); boolean grouped = false; List<String> others = new ArrayList<String>(); for (Entry<Taxon, Long> entry : eesPerTaxonValueSorted.descendingSet()) { String tname = entry.getKey().getCommonName(); if (StringUtils.isBlank(tname)) tname = entry.getKey().getScientificName(); if (entry.getValue() == 0) continue; if (groupIntoOther(entry.getValue(), expressionExperimentCount, groupBelow)) { grouped = true; others.add(tname); } else { googleLabelsColls.add(tname); } } if (grouped) { googleLabelsColls.add(StringUtils.abbreviate(StringUtils.join(others, ", "), 50)); } String googleLabels = StringUtils.join(googleLabelsColls, '|'); mav.addObject("googleData", googleData); mav.addObject("googleLabels", googleLabels); }