List of usage examples for java.util TreeMap get
public V get(Object key)
From source file:com.genentech.application.calcProps.SDFCalcProps.java
private static void printProperties(Set<Calculator> calculators, boolean showHidden) { //Print properties by alphabetical order TreeMap<String, String> sortedCalcs = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); for (Calculator calc : calculators) { if (calc.isPublic()) { sortedCalcs.put(calc.getName(), calc.getHelpText()); } else if (showHidden == true) {//print non public props as well sortedCalcs.put(calc.getName(), calc.getHelpText()); }// w ww. j a va2 s. com } for (String key : sortedCalcs.keySet()) { System.err.println(key + ":\t" + sortedCalcs.get(key)); } }
From source file:org.apache.hadoop.hbase.util.RegionSplitCalculator.java
/** * Find specified number of top ranges in a big overlap group. * It could return less if there are not that many top ranges. * Once these top ranges are excluded, the big overlap group will * be broken into ranges with no overlapping, or smaller overlapped * groups, and most likely some holes.//w w w . ja v a2s. c o m * * @param bigOverlap a list of ranges that overlap with each other * @param count the max number of ranges to find * @return a list of ranges that overlap with most others */ public static <R extends KeyRange> List<R> findBigRanges(Collection<R> bigOverlap, int count) { List<R> bigRanges = new ArrayList<R>(); // The key is the count of overlaps, // The value is a list of ranges that have that many overlaps TreeMap<Integer, List<R>> overlapRangeMap = new TreeMap<Integer, List<R>>(); for (R r : bigOverlap) { // Calculates the # of overlaps for each region // and populates rangeOverlapMap byte[] startKey = r.getStartKey(); byte[] endKey = specialEndKey(r); int overlappedRegions = 0; for (R rr : bigOverlap) { byte[] start = rr.getStartKey(); byte[] end = specialEndKey(rr); if (BYTES_COMPARATOR.compare(startKey, end) < 0 && BYTES_COMPARATOR.compare(endKey, start) > 0) { overlappedRegions++; } } // One region always overlaps with itself, // so overlappedRegions should be more than 1 // for actual overlaps. if (overlappedRegions > 1) { Integer key = Integer.valueOf(overlappedRegions); List<R> ranges = overlapRangeMap.get(key); if (ranges == null) { ranges = new ArrayList<R>(); overlapRangeMap.put(key, ranges); } ranges.add(r); } } int toBeAdded = count; for (Integer key : overlapRangeMap.descendingKeySet()) { List<R> chunk = overlapRangeMap.get(key); int chunkSize = chunk.size(); if (chunkSize <= toBeAdded) { bigRanges.addAll(chunk); toBeAdded -= chunkSize; if (toBeAdded > 0) continue; } else { // Try to use the middle chunk in case the overlapping is // chained, for example: [a, c), [b, e), [d, g), [f h)... // In such a case, sideline the middle chunk will break // the group efficiently. int start = (chunkSize - toBeAdded) / 2; int end = start + toBeAdded; for (int i = start; i < end; i++) { bigRanges.add(chunk.get(i)); } } break; } return bigRanges; }
From source file:br.ufrgs.inf.dsmoura.repository.model.loadData.LoadLists.java
@SuppressWarnings("unused") private static void loadDomainAndSubdomain() { // TreeMap<String, ArrayList<String>> domains = readFileCcs98(); // TreeMap<String, ArrayList<String>> domains = readFileDomains(); TreeMap<String, ArrayList<String>> domains = getAllDomainsAndSubDomains(); for (String key : domains.keySet()) { ApplicationDomain ad = new ApplicationDomain(); ad.setName(key);/*from w w w. j a v a2s . c o m*/ ad = (ApplicationDomain) GenericDAO.getInstance().insert(ad); logger.info("ApplicationDomain inserted: " + key); ArrayList<String> subdomains = domains.get(key); Collections.sort(subdomains); for (String s : subdomains) { ApplicationSubdomain as = new ApplicationSubdomain(); as.setName(s); as.setApplicationDomain(ad); GenericDAO.getInstance().insert(as); logger.info("ApplicationSubdomain inserted: " + s); } } }
From source file:gsn.vsensor.EmailVirtualSensor.java
public boolean initialize() { TreeMap<String, String> params = getVirtualSensorConfiguration().getMainClassInitialParams(); if (params.get(INITPARAM_SUBJECT) != null) subject = params.get(INITPARAM_SUBJECT); if (params.get(INITPARAM_RECEIVER) != null) receiverEmail = params.get(INITPARAM_RECEIVER); if (params.get(INITPARAM_SENDER) != null) senderEmail = params.get(INITPARAM_SENDER); else {/*from w w w.ja va 2s .c o m*/ logger.error("The parameter *" + INITPARAM_SENDER + "* is missing from the virtual sensor processing class's initialization."); logger.error("Loading the virtual sensor failed"); return false; } if (params.get(INITPARAM_SERVER) != null) mailServer = params.get(INITPARAM_SERVER); else { logger.error("The parameter *" + INITPARAM_SERVER + "* is missing from the virtual sensor processing class's initialization."); logger.error("Loading the virtual sensor failed"); return false; } try { email = new SimpleEmail(); email.setHostName(mailServer); email.setFrom(senderEmail); email.setSubject(subject); } catch (Exception e) { logger.error("Email initialization failed", e); return false; } return true; }
From source file:com.act.lcms.db.analysis.AnalysisHelper.java
/** * This function scores the various metlin ions from different standard ion results, sorts them and picks the * best ion. This is done by adding up the indexed positions of the ion in each sorted entry of the list of * standard ion results. Since the entries in the standard ion results are sorted, the lower magnitude summation ions * are better than the larger magnitude summations. Then, we add another feature, in this case, the normalized SNR/maxSNR * but multiplying the positional score with the normalized SNR. The exact calculation is as follows: * score = positional_score * (1 - SNR(i)/maxSNR). We have to do the (1 - rel_snr) since we choose the lowest score, * so if the rel_snr is huge (ie a good signal), the overall magnitude of score will reduce, which makes that a better * ranking for the ion. We then do a post filtering on these scores based on if we have only positive/negative scans * from the scan files which exist in the context of the caller. * @param standardIonResults The list of standard ion results * @param curatedMetlinIons A map from standard ion result to the best curated ion that was manual inputted. * @param areOtherPositiveModeScansAvailable This boolean is used to post filter and pick a positive metlin ion if and * only if positive ion mode scans are available. * @param areOtherNegativeModeScansAvailable This boolean is used to post filter and pick a negative metlin ion if and * only if negative ion mode scans are available. * @return The best metlin ion or null if none can be found *///from www . j a v a 2 s .c o m public static String scoreAndReturnBestMetlinIonFromStandardIonResults( List<StandardIonResult> standardIonResults, Map<StandardIonResult, String> curatedMetlinIons, boolean areOtherPositiveModeScansAvailable, boolean areOtherNegativeModeScansAvailable) { if (standardIonResults == null) { return null; } // We find the maximum SNR values for each standard ion result so that we can normalize individual SNR scores // during scoring. HashMap<StandardIonResult, Double> resultToMaxSNR = new HashMap<>(); for (StandardIonResult result : standardIonResults) { Double maxSNR = 0.0d; for (Map.Entry<String, XZ> resultoDoublePair : result.getAnalysisResults().entrySet()) { if (resultoDoublePair.getValue().getIntensity() > maxSNR) { maxSNR = resultoDoublePair.getValue().getIntensity(); } } resultToMaxSNR.put(result, maxSNR); } Map<String, Double> metlinScore = new HashMap<>(); Set<String> ions = standardIonResults.get(0).getAnalysisResults().keySet(); // For each ion, iterate through all the ion results to find the position of that ion in each result set (since the // ions are sorted) and then multiply that by a normalized value of the SNR. for (String ion : ions) { for (StandardIonResult result : standardIonResults) { Integer counter = 0; for (String localIon : result.getAnalysisResults().keySet()) { counter++; if (localIon.equals(ion)) { Double ionScore = metlinScore.get(ion); if (ionScore == null) { // Normalize the sample's SNR by dividing it by the maxSNR. Then we multiple a variant of it to the counter // score so that if the total magnitude of the score is lower, the ion is ranked higher. ionScore = (1.0 * counter) * (1 - (result.getAnalysisResults().get(ion).getIntensity() / resultToMaxSNR.get(result))); } else { ionScore += (1.0 * counter) * (1 - (result.getAnalysisResults().get(ion).getIntensity() / resultToMaxSNR.get(result))); } metlinScore.put(ion, ionScore); break; } } } } for (Map.Entry<StandardIonResult, String> resultToIon : curatedMetlinIons.entrySet()) { // Override all the scores of the manually curated standard ion result and set them to the highest rank. // Ideally, the user has been consistent for the best metlin ion across similar standard ion results, so // tie breakers will not happen. If a tie happen, it is broken arbitrarily. metlinScore.put(resultToIon.getValue(), MANUAL_OVERRIDE_BEST_SCORE); } TreeMap<Double, List<String>> sortedScores = new TreeMap<>(); for (String ion : metlinScore.keySet()) { if (MS1.getIonModeOfIon(ion) != null) { if ((MS1.getIonModeOfIon(ion).equals(MS1.IonMode.POS) && areOtherPositiveModeScansAvailable) || (MS1.getIonModeOfIon(ion).equals(MS1.IonMode.NEG) && areOtherNegativeModeScansAvailable)) { List<String> ionBucket = sortedScores.get(metlinScore.get(ion)); if (ionBucket == null) { ionBucket = new ArrayList<>(); } ionBucket.add(ion); sortedScores.put(metlinScore.get(ion), ionBucket); } } } if (sortedScores.size() == 0) { LOGGER.error( "Could not find any ions corresponding to the positive and negative scan mode conditionals"); return null; } else { List<String> topMetlinIons = sortedScores.get(sortedScores.keySet().iterator().next()); // In cases of a tie breaker, simply choose the first ion. return topMetlinIons.get(0); } }
From source file:io.fabric8.kit.enricher.api.EnrichersConfig.java
public String getConfig(String name, String key) { TreeMap enricherMap = config.get(name); return enricherMap != null ? (String) enricherMap.get(key) : null; }
From source file:com.sangupta.jerry.oauth.OAuthUtils.java
/** * Generate a sorted parameter string for the given parameters. All * parameters are appended into a string form. * /*from w w w . j ava 2 s. c o m*/ * @param params * the request parameters that need to be appended * * @param encodeParamValues * whether to URL encode the parameters or not * * @return the URL query string representation of all parameters */ public static String generateParamString(TreeMap<String, String> params, boolean encodeParamValues) { if (AssertUtils.isEmpty(params)) { return StringUtils.EMPTY_STRING; } StringBuilder builder = new StringBuilder(); boolean first = true; for (String key : params.keySet()) { if (first) { first = false; } else { builder.append('&'); } builder.append(key); builder.append("="); if (encodeParamValues) { builder.append(UriUtils.encodeURIComponent(params.get(key), true)); } else { builder.append(params.get(key)); } } return builder.toString(); }
From source file:io.fabric8.maven.core.config.ProcessorConfig.java
public String getConfig(String name, String key) { TreeMap processorMap = config.get(name); return processorMap != null ? (String) processorMap.get(key) : null; }
From source file:com.tassadar.multirommgr.installfragment.UbuntuManifest.java
public UbuntuChannel findChannel(String full_name) { String flavour_name, channel_name; int idx = full_name.indexOf('/'); if (idx == -1) { flavour_name = NO_FLAVOUR;//from w w w. j a va 2 s . c o m channel_name = full_name; } else { flavour_name = full_name.substring(0, idx); channel_name = full_name.substring(idx + 1); } TreeMap<String, UbuntuChannel> channelMap = m_flavours.get(flavour_name); if (channelMap != null) return channelMap.get(channel_name); return null; }
From source file:net.triptech.buildulator.model.DataGrid.java
/** * Gets the row fields for the supplied index. * * @param rowNumber the row number//from ww w . java2 s . co m * @return the row fields */ public List<String> getRowFields(final int rowNumber) { List<String> data = new ArrayList<String>(); if (body.containsKey(rowNumber)) { TreeMap<Integer, String> row = body.get(rowNumber); for (int index : row.keySet()) { data.add(row.get(index)); } } return data; }