List of usage examples for java.util TreeMap put
public V put(K key, V value)
From source file:Main.java
public static <T> TreeMap<String, T> arraryToTreeMap(T[] itemsArray) { TreeMap<String, T> map = new TreeMap<String, T>(); T[] arrayOfObject = itemsArray;/* w w w .j a v a 2 s .co m*/ int j = itemsArray.length; for (int i = 0; i < j; i++) { T s = arrayOfObject[i]; map.put(s.toString(), s); } return map; }
From source file:com.cloudant.mazha.json.JSONHelperTest.java
@BeforeClass public static void beforeClass() throws Exception { expectedJSONMap = new TreeMap<String, Object>(); expectedJSONMap.put("Sunrise", true); expectedJSONMap.put("Sunset", false); expectedJSONMap.put("Data", "A run to the head of the blood"); TreeMap<String, Object> organizer = new TreeMap<String, Object>(); organizer.put("Name", "Tom"); organizer.put("Sex", "Male"); expectedJSONMap.put("Organizer", organizer); ArrayList<Number> fullhours = new ArrayList<Number>(); fullhours.add(1);/*from w w w . jav a 2 s . c o m*/ fullhours.add(2); fullhours.add(3); fullhours.add(4); fullhours.add(5); fullhours.add(6); fullhours.add(7); fullhours.add(8); fullhours.add(9); fullhours.add(10); expectedJSONMap.put("FullHours", fullhours); TreeMap<String, Object> football = new TreeMap<String, Object>(); football.put("Name", "Football"); football.put("Duration", 2); football.put("DurationUnit", "Hours"); TreeMap<String, Object> breakfast = new TreeMap<String, Object>(); breakfast.put("Name", "Breakfast"); breakfast.put("Duration", 40); breakfast.put("DurationUnit", "Minutes"); ArrayList<String> attendees = new ArrayList<String>(); attendees.add("Jan"); attendees.add("Damien"); attendees.add("Laura"); attendees.add("Gwendolyn"); attendees.add("Roseanna"); breakfast.put("Attendees", attendees); ArrayList<TreeMap> activities = new ArrayList<TreeMap>(); activities.add(football); activities.add(breakfast); expectedJSONMap.put("Activities", activities); expectedJson = FileUtils.readFileToString(TestUtils.loadFixture("fixture/json_helper_compacted.json")); }
From source file:com.opengamma.analytics.financial.provider.sensitivity.inflation.MultipleCurrencyInflationSensitivity.java
/** * Create a new multiple currency sensitivity with one currency. * @param ccy The currency. Not null./*from w w w . j a va 2 s.com*/ * @param sensitivity The sensitivity associated to the currency. Not null. * @return The multiple currency sensitivity. */ public static MultipleCurrencyInflationSensitivity of(final Currency ccy, final InflationSensitivity sensitivity) { ArgumentChecker.notNull(ccy, "Currency"); ArgumentChecker.notNull(sensitivity, "Sensitivity"); final TreeMap<Currency, InflationSensitivity> map = new TreeMap<>(); map.put(ccy, sensitivity); return new MultipleCurrencyInflationSensitivity(map); }
From source file:com.opengamma.analytics.financial.forex.method.MultipleCurrencyInterestRateCurveSensitivity.java
/** * Create a new multiple currency sensitivity with one currency. * @param ccy The currency. Not null.//from ww w . j av a 2s . c o m * @param sensitivity The sensitivity associated to the currency. The sensitivity is used directly (not copied). Not null. * @return The multiple currency sensitivity. */ public static MultipleCurrencyInterestRateCurveSensitivity of(final Currency ccy, final InterestRateCurveSensitivity sensitivity) { ArgumentChecker.notNull(ccy, "Currency"); ArgumentChecker.notNull(sensitivity, "Sensitivity"); final TreeMap<Currency, InterestRateCurveSensitivity> map = new TreeMap<>(); map.put(ccy, sensitivity); return new MultipleCurrencyInterestRateCurveSensitivity(map); }
From source file:com.azaptree.services.spring.application.SpringApplicationService.java
private static void logDebugSystemProperties(final Logger log) { Assert.notNull(log);/*from www . j av a 2 s .c o m*/ if (log.isDebugEnabled()) { final TreeMap<String, String> sysProps = new TreeMap<>(); for (final Map.Entry<Object, Object> entry : System.getProperties().entrySet()) { sysProps.put(entry.getKey().toString(), entry.getValue().toString()); } final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final PrintStream ps = new PrintStream(bos); for (final Map.Entry<String, String> entry : sysProps.entrySet()) { ps.print(entry.getKey()); ps.print('='); ps.println(entry.getValue()); } log.debug("System Properties:\n{}", bos); } }
From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.MultipleCurrencyMulticurveSensitivity.java
/** * Create a new multiple currency sensitivity with one currency. * @param ccy The currency. Not null./*from www . ja v a 2s . co m*/ * @param sensitivity The sensitivity associated to the currency. Not null. * @return The multiple currency sensitivity. */ public static MultipleCurrencyMulticurveSensitivity of(final Currency ccy, final MulticurveSensitivity sensitivity) { ArgumentChecker.notNull(ccy, "Currency"); ArgumentChecker.notNull(sensitivity, "Sensitivity"); final TreeMap<Currency, MulticurveSensitivity> map = new TreeMap<>(); map.put(ccy, sensitivity); return new MultipleCurrencyMulticurveSensitivity(map); }
From source file:com.opengamma.analytics.financial.interestrate.market.description.MultipleCurrencyCurveSensitivityMarket.java
/** * Create a new multiple currency sensitivity with one currency. * @param ccy The currency. Not null.// w w w . j a v a 2 s. com * @param sensitivity The sensitivity associated to the currency. Not null. * @return The multiple currency sensitivity. */ public static MultipleCurrencyCurveSensitivityMarket of(final Currency ccy, final CurveSensitivityMarket sensitivity) { ArgumentChecker.notNull(ccy, "Currency"); ArgumentChecker.notNull(sensitivity, "Sensitivity"); final TreeMap<Currency, CurveSensitivityMarket> map = new TreeMap<Currency, CurveSensitivityMarket>(); map.put(ccy, sensitivity); return new MultipleCurrencyCurveSensitivityMarket(map); }
From source file:cit360.sandbox.BackEndMenu.java
public static void ticketPrices() { TreeMap ageGroup = new TreeMap(); // Add some ageGroup. ageGroup.put("Adult", 8.75); ageGroup.put("Child", 5.50); ageGroup.put("Senior Citizen", 5.25); ageGroup.put("Military Veteran", 5.00); // Iterate over all ageGroup, using the keySet method. for (Object key : ageGroup.keySet()) System.out.println(key + " - $" + ageGroup.get(key)); System.out.println();/*from ww w . j a v a 2 s . c o m*/ System.out.println("Highest key: " + ageGroup.lastKey()); System.out.println("Lowest key: " + ageGroup.firstKey()); System.out.println("\nPrinting all values: "); for (Object val : ageGroup.values()) System.out.println("$" + val); System.out.println(); // Clear all values. ageGroup.clear(); // Equals to zero. System.out.println("After clear operation, size: " + ageGroup.size()); }
From source file:eval.dataset.ParseWikiLog.java
private static void updateMap(TreeMap<String, Set<String>> userPageMap, String user, String page) { if (userPageMap.containsKey(user)) { userPageMap.get(user).add(page); } else {/* www. j a va2s .c o m*/ Set<String> pageSet = new TreeSet(); pageSet.add(page); userPageMap.put(user, pageSet); } }
From source file:TokenizerUtil.java
public static Map<String, String> convertCSVStringToMap(String s) { TreeMap<String, String> map = new TreeMap<String, String>(); StringTokenizer st = new StringTokenizer(s, "|"); while (st.hasMoreTokens()) { String keyToken = st.nextToken(); String valueToken = st.nextToken(); map.put(keyToken, valueToken); }//from w w w. ja v a2s .c o m return map; }