Example usage for java.util HashMap put

List of usage examples for java.util HashMap put

Introduction

In this page you can find the example usage for java.util HashMap put.

Prototype

public V put(K key, V value) 

Source Link

Document

Associates the specified value with the specified key in this map.

Usage

From source file:Main.java

@SuppressWarnings("rawtypes")
public static Map<String, Integer> swapIntKeysAndStrValues(Map<Integer, String> hm) {
    HashMap<String, Integer> nhm = new HashMap<String, Integer>();
    Set<?> s = hm.entrySet();
    Iterator<?> it = s.iterator();
    while (it.hasNext()) {
        Map.Entry m = (Map.Entry) it.next();
        nhm.put((String) m.getValue(), (Integer) m.getKey());
    }/*from w w w. jav a 2 s .  c  om*/
    return nhm;
}

From source file:com.wormsim.LaunchFromCodeMain.java

private static SimulationConditions makeCustomInitialConditions() {
    HashMap<String, IntegerDistribution> map = new HashMap<>();

    map.put("TestStrain L2", new EnumeratedIntegerDistribution(new int[] { 1 }));

    return new SimulationConditions(new ConstantRealDistribution(10000.0),
            // new NormalDistribution(1000.0, 200.0),
            new RealDistribution[] { new ConstantRealDistribution(0.0) }, map);
}

From source file:Main.java

private static void addToUsed(HashMap<Integer, Integer> used, Integer key, Integer value) {
    if (used.containsKey(value)) {
        value = used.get(value);/*from   w ww .j a  va  2s .c o  m*/
        addToUsed(used, key, value);
    }
    used.put(key, value);
}

From source file:com.imaginary.home.cloud.Configuration.java

static public @Nonnull Configuration getConfiguration() throws PersistenceException {
    Configuration c = getCache().get("configuration");

    if (c == null) {
        HashMap<String, Object> state = new HashMap<String, Object>();

        state.put("key", "configuration");
        state.put("salt", generateToken(16, 16));

        Transaction xaction = Transaction.getInstance();

        try {//w w w. jav a 2 s  .  co m
            c = getCache().create(xaction, state);
            xaction.commit();
        } finally {
            xaction.rollback();
        }
    }
    return c;
}

From source file:Main.java

public static HashMap<Object, Action> createActionTable(JTextComponent textComponent) {
    HashMap<Object, Action> actions = new HashMap<>();
    Action[] actionsArray = textComponent.getActions();
    for (int i = 0; i < actionsArray.length; i++) {
        Action a = actionsArray[i];
        actions.put(a.getValue(Action.NAME), a);
    }// w  ww .j av  a2  s  .co m
    return actions;
}

From source file:com.soomla.store.domain.data.StaticPriceModel.java

/**
 * Creates a {@link StaticPriceModel} with the given JSONObject.
 * @param jsonObject is a JSONObject representation of the required {@link StaticPriceModel}.
 * @return an instance of {@link StaticPriceModel}.
 * @throws JSONException//from  ww w .  j  a  v  a  2s .co  m
 */
public static StaticPriceModel fromJSONObject(JSONObject jsonObject) throws JSONException {
    JSONObject valuesJSONObject = jsonObject.getJSONObject(JSONConsts.GOOD_PRICE_MODEL_VALUES);
    Iterator<?> keys = valuesJSONObject.keys();
    HashMap<String, Integer> values = new HashMap<String, Integer>();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        values.put(key, valuesJSONObject.getInt(key));
    }

    return new StaticPriceModel(values);
}

From source file:net.bither.util.ExchangeUtil.java

private static AbstractMap<Currency, Double> parseCurrenciesRate(JSONObject json) throws JSONException {
    HashMap<Currency, Double> currencyDoubleHashMap = new HashMap<Currency, Double>();
    currencyDoubleHashMap.put(Currency.USD, 1.0);
    for (Currency currency : Currency.values()) {
        if (!json.isNull(currency.getName())) {
            currencyDoubleHashMap.put(currency, json.getDouble(currency.getName()));
        }//from  ww  w .  j  a v a2  s.c  o m
    }
    return currencyDoubleHashMap;
}

From source file:com.opengamma.analytics.financial.interestrate.InterestRateCurveSensitivity.java

/**
 * Builder from a curve name and a list of sensitivities.
 * @param name The name, not null//from   www. j a va2s  . co  m
 * @param sensitivityCurve The sensitivity as a list, not null
 * @return The interest rate curve sensitivity.
 */
public static InterestRateCurveSensitivity of(final String name, final List<DoublesPair> sensitivityCurve) {
    ArgumentChecker.notNull(name, "Curve name");
    ArgumentChecker.notNull(sensitivityCurve, "sensitivity");
    final HashMap<String, List<DoublesPair>> ircs = new HashMap<>();
    ircs.put(name, sensitivityCurve);
    return new InterestRateCurveSensitivity(ircs);
}

From source file:com.kakao.http.HttpRequestTask.java

private static HashMap<String, String> createKAHeader() {
    HashMap<String, String> kaHeader = new HashMap<String, String>();
    kaHeader.put(CommonProtocol.KA_HEADER_KEY, SystemInfo.getKAHeader());
    return kaHeader;
}

From source file:com.groupon.odo.proxylib.Utils.java

public static HashMap<String, Object> getJQGridJSON(Object row, String rowName) {
    HashMap<String, Object> returnVal = new HashMap<String, Object>();
    returnVal.put("records", 1);
    returnVal.put("total", 1);
    returnVal.put("page", 1);
    returnVal.put(rowName, row);//from  www  .  ja  v  a  2s.com
    return returnVal;
}