List of usage examples for java.util TreeMap putAll
public void putAll(Map<? extends K, ? extends V> map)
From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.MultipleCurrencyMulticurveSensitivity.java
/** * Create a new multiple currency sensitivity by adding another multiple currency sensitivity. * For each currency in the other multiple currency sensitivity, the currency and its associated sensitivity are added. * @param other The multiple currency sensitivity. Not null. * @return The new multiple currency sensitivity. *///from ww w . jav a 2 s .c o m public MultipleCurrencyMulticurveSensitivity plus(final MultipleCurrencyMulticurveSensitivity other) { ArgumentChecker.notNull(other, "Sensitivity"); final TreeMap<Currency, MulticurveSensitivity> map = new TreeMap<>(); map.putAll(_sensitivity); MultipleCurrencyMulticurveSensitivity result = new MultipleCurrencyMulticurveSensitivity(map); for (final Currency loopccy : other._sensitivity.keySet()) { result = result.plus(loopccy, other.getSensitivity(loopccy)); } return result; }
From source file:com.opengamma.analytics.financial.interestrate.market.description.MultipleCurrencyCurveSensitivityMarket.java
/** * Create a new multiple currency sensitivity by adding another multiple currency sensitivity. * For each currency in the other multiple currency sensitivity, the currency and its associated sensitivity are added. * @param other The multiple currency sensitivity. Not null. * @return The new multiple currency sensitivity. *//* w w w .jav a 2 s. c o m*/ public MultipleCurrencyCurveSensitivityMarket plus(final MultipleCurrencyCurveSensitivityMarket other) { ArgumentChecker.notNull(other, "Sensitivity"); final TreeMap<Currency, CurveSensitivityMarket> map = new TreeMap<Currency, CurveSensitivityMarket>(); map.putAll(_sensitivity); MultipleCurrencyCurveSensitivityMarket result = new MultipleCurrencyCurveSensitivityMarket(map); for (final Currency loopccy : other._sensitivity.keySet()) { result = result.plus(loopccy, other.getSensitivity(loopccy)); } return result; }
From source file:edu.utexas.cs.tactex.utilityestimation.UtilityArchitectureActionGenerator.java
/** * Potential template method - any function call can be refactored to an interface *//*from w ww. j a va2 s . c o m*/ @Override public List<TariffMessage> selectTariffActions(boolean useCanUse, HashMap<TariffSpecification, HashMap<CustomerInfo, Integer>> tariffSubscriptions, List<TariffSpecification> competingTariffs, MarketManager marketManager, ContextManager contextManager, CostCurvesPredictor costCurvesPredictor, int currentTimeslot, boolean useRevoke, Broker me) { boolean customerPerspective = true; HashMap<CustomerInfo, ArrayRealVector> customer2estimatedEnergy = energyPredictionManager .getAbout7dayPredictionForAllCustomers(customerPerspective, currentTimeslot, /*false*/ true); // false: don't use fixed-rate only, use the standard one TreeMap<Double, TariffSpecification> sortedTariffs = tariffOptimizer.optimizeTariffs(tariffSubscriptions, customer2estimatedEnergy, competingTariffs, marketManager, contextManager, costCurvesPredictor, currentTimeslot, me); log.info("Estimated Utilities: "); for (Entry<Double, TariffSpecification> e : sortedTariffs.entrySet()) { log.info("u: " + e.getKey() + " spec: " + e.getValue()); } TreeMap<Double, TariffMessage> sortedTariffActions = new TreeMap<Double, TariffMessage>(); sortedTariffActions.putAll(sortedTariffs); if (useRevoke) { TreeMap<Double, TariffSpecification> sortedTariffRevokes = tariffOptimizerRevoke.optimizeTariffs( tariffSubscriptions, customer2estimatedEnergy, competingTariffs, marketManager, contextManager, costCurvesPredictor, currentTimeslot, me); log.info("(Revoke) Estimated Utilities: "); for (Entry<Double, TariffSpecification> e : sortedTariffRevokes.entrySet()) { log.info("u: " + e.getKey() + " spec: " + e.getValue()); } // fill util=>action for (Entry<Double, TariffSpecification> entry : sortedTariffRevokes.entrySet()) { TariffSpecification spec = entry.getValue(); if (null == spec) { sortedTariffActions.put(entry.getKey(), spec); } else { sortedTariffActions.put(entry.getKey(), new TariffRevoke(me, spec)); } } } List<TariffMessage> tariffActionsToExecute = selectBestActions(currentTimeslot, sortedTariffActions, tariffSubscriptions.keySet()); return tariffActionsToExecute; }
From source file:hermes.ext.ems.TibcoEMSAdmin.java
public Map getStatistics(final DestinationConfig destination) throws JMSException { try {//from w ww . j av a 2 s.c o m final DestinationInfo info = getDestinationInfo(destination); final TreeMap rval = new TreeMap(); rval.putAll(PropertyUtils.describe(info)); rval.remove("inboundStatistics"); rval.remove("outboundStatistics"); rval.put("inboundByteRate", new Long(info.getInboundStatistics().getByteRate())); rval.put("inboundMessageRate", new Long(info.getInboundStatistics().getMessageRate())); rval.put("inboundTotalBytes", new Long(info.getInboundStatistics().getTotalBytes())); rval.put("inboundTotalMessages", new Long(info.getInboundStatistics().getTotalMessages())); rval.put("outboundByteRate", new Long(info.getOutboundStatistics().getByteRate())); rval.put("outboundMessageRate", new Long(info.getOutboundStatistics().getMessageRate())); rval.put("outboundTotalBytes", new Long(info.getOutboundStatistics().getTotalBytes())); rval.put("outboundTotalMessages", new Long(info.getOutboundStatistics().getTotalMessages())); return rval; } catch (IllegalAccessException e) { throw new HermesException(e); } catch (InvocationTargetException e) { throw new HermesException(e); } catch (NoSuchMethodException e) { throw new HermesException(e); } }
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())); }/* w w w .j av a 2 s . c o m*/ return texts.values(); }
From source file:com.linuxbox.enkive.imap.mongo.MongoImapAccountCreator.java
@Override public void addImapMessages(String username, Date fromDate, Date toDate) throws MessageSearchException { Calendar startTime = Calendar.getInstance(); startTime.setTime(fromDate);/*from ww w . ja va 2s . c om*/ Calendar endTime = Calendar.getInstance(); endTime.setTime(toDate); while (startTime.before(endTime)) { Calendar endOfMonth = (Calendar) startTime.clone(); endOfMonth.set(Calendar.DAY_OF_MONTH, endOfMonth.getActualMaximum(Calendar.DAY_OF_MONTH)); if (endOfMonth.after(endTime)) endOfMonth = (Calendar) endTime.clone(); // Need to get all messages to add Set<String> messageIdsToAdd = getMailboxMessageIds(username, startTime.getTime(), endOfMonth.getTime()); // Need to add messages // Get top UID, add from there if (!messageIdsToAdd.isEmpty()) { // Need to check if folder exists, if not create it and add to // user // mailbox list DBObject mailboxObject = getMessagesFolder(username, startTime.getTime()); @SuppressWarnings("unchecked") HashMap<String, String> mailboxMsgIds = (HashMap<String, String>) mailboxObject .get(MongoEnkiveImapConstants.MESSAGEIDS); TreeMap<String, String> sortedMsgIds = new TreeMap<String, String>(); sortedMsgIds.putAll(mailboxMsgIds); long i = 0; if (!sortedMsgIds.isEmpty()) i = Long.valueOf(sortedMsgIds.lastKey()); for (String msgId : messageIdsToAdd) { i++; mailboxMsgIds.put(((Long.toString(i))), msgId); } mailboxObject.put(MongoEnkiveImapConstants.MESSAGEIDS, mailboxMsgIds); imapCollection.findAndModify(new BasicDBObject("_id", mailboxObject.get("_id")), mailboxObject); } startTime.set(Calendar.DAY_OF_MONTH, 1); startTime.add(Calendar.MONTH, 1); } }
From source file:ws.project.languagebasedlexiconanalisys.LexiconProcessor.java
public TreeMap constructSortedMap(Map<String, HashSet<String>> m) { Map<String, HashSet<String>> temp = new HashMap(); ValueComparator comp = new ValueComparator(temp); TreeMap<String, HashSet<String>> sorted = new TreeMap(comp); for (Map.Entry<String, HashSet<String>> e : m.entrySet()) temp.put(e.getKey(), e.getValue()); sorted.putAll(m); return sorted; }
From source file:jenkins.plugins.publish_over.BapPublisher.java
public void setEffectiveEnvironmentInBuildInfo(final BPBuildInfo buildInfo) { buildInfo.setVerbose(verbose);/*www.j a v a2 s . co m*/ final BPBuildEnv current = buildInfo.getCurrentBuildEnv(); final BPBuildEnv target = buildInfo.getTargetBuildEnv(); if (target == null) { buildInfo.setEnvVars(current.getEnvVars()); buildInfo.setBaseDirectory(current.getBaseDirectory()); buildInfo.setBuildTime(current.getBuildTime()); } else { buildInfo.setBaseDirectory( useWorkspaceInPromotion ? current.getBaseDirectory() : target.getBaseDirectory()); buildInfo.setBuildTime(usePromotionTimestamp ? current.getBuildTime() : target.getBuildTime()); final TreeMap<String, String> effectiveEnvVars = current .getEnvVarsWithPrefix(BPBuildInfo.PROMOTION_ENV_VARS_PREFIX); effectiveEnvVars.putAll(target.getEnvVars()); buildInfo.setEnvVars(effectiveEnvVars); } }
From source file:org.cloudata.core.client.TabletLocationCache.java
public void clearTabletCache(String tableName, TabletInfo tabletInfo) { if (tabletInfo == null) { return;//from w w w.j a v a 2 s .co m } cacheLock.obtainWriteLock(); try { if (Constants.TABLE_NAME_ROOT.equals(tableName)) { rootTablet = null; } else if (Constants.TABLE_NAME_META.equals(tableName)) { rootCache.clear(); metaCache.clear(); } else { TreeMap<Row.Key, TabletInfo> tempMetaCache = new TreeMap<Row.Key, TabletInfo>(); tempMetaCache.putAll(metaCache); for (Map.Entry<Row.Key, TabletInfo> entry : tempMetaCache.entrySet()) { Row.Key rowKey = entry.getKey(); TabletInfo entryTabletInfo = entry.getValue(); if (entryTabletInfo.equals(tabletInfo)) { metaCache.remove(rowKey); } } } } finally { cacheLock.releaseWriteLock(); } }
From source file:webcralwerproject1.Webcrawler.java
public TreeMap<String, Integer> sortTermFreq(HashMap<String, Integer> termfreq) { //The comparator is used to sort the TreeMap by keys. Comparator<String> comparator = new ValueComparator(termfreq); //Creating a TreeMap to enable sorting by keys in our termfreq hashmap TreeMap<String, Integer> sortedMap = new TreeMap<String, Integer>(comparator); sortedMap.putAll(termfreq); return sortedMap; }