/** * Creates a hash map from two index-aligned arrays of key-value pairs. */ public static IntDoubleHashMap from(int[] keys, double[] values) { if (keys.length != values.length) { throw new IllegalArgumentException("Arrays of keys and values must have an identical length."); } IntDoubleHashMap map = new IntDoubleHashMap(keys.length); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; }
/** * Puts all key/value pairs from a given iterable into this map. */ @Override public int putAll(Iterable<? extends IntDoubleCursor> iterable){ final int count = size(); for (IntDoubleCursor c : iterable) { put(c.key, c.value); } return size() - count; }
/** * {@inheritDoc} */ @Override public int putAll(IntDoubleAssociativeContainer container) { final int count = size(); for (IntDoubleCursor c : container) { put(c.key, c.value); } return size() - count; }
public void put(int key, double value) { g_map.put(key, value); }
/** * Set a stat to the specified double value. Creates the stat * if the stat does not yet exist. * * @param metric the metric to update * @param value the value to set */ public void setDoubleStat(MetricDef metric, double value){ doubleMetrics.put(metric.metricId(), value); }
public void setDoubleStat(MetricDef metric, double value){ doubleMetrics.put(metric.metricId(), value); }
/** * Creates a hash map from two index-aligned arrays of key-value pairs. */ public static IntDoubleHashMap from(int[] keys, double[] values) { if (keys.length != values.length) { throw new IllegalArgumentException("Arrays of keys and values must have an identical length."); } IntDoubleHashMap map = new IntDoubleHashMap(keys.length); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; }
/** * <a href="http://trove4j.sourceforge.net">Trove</a>-inspired API method. An equivalent * of the following code: * <pre> * if (!map.containsKey(key)) map.put(value); * </pre> * * @param key The key of the value to check. * @param value The value to put if <code>key</code> does not exist. * @return <code>true</code> if <code>key</code> did not exist and <code>value</code> * was placed in the map. */ public boolean putIfAbsent(int key, double value) { if (!containsKey(key)) { put(key, value); return true; } else { return false; } }
/** * Puts all key/value pairs from a given iterable into this map. */ @Override public int putAll(Iterable<? extends IntDoubleCursor> iterable){ final int count = size(); for (IntDoubleCursor c : iterable) { put(c.key, c.value); } return size() - count; }
/** * {@inheritDoc} */ @Override public int putAll(IntDoubleAssociativeContainer container) { final int count = size(); for (IntDoubleCursor c : container) { put(c.key, c.value); } return size() - count; }
/** * If <code>key</code> exists, <code>putValue</code> is inserted into the map, * otherwise any existing value is incremented by <code>additionValue</code>. * * @param key * The key of the value to adjust. * @param putValue * The value to put if <code>key</code> does not exist. * @param incrementValue * The value to add to the existing value if <code>key</code> exists. * @return Returns the current value associated with <code>key</code> (after * changes). */ @Override public double putOrAdd(int key, double putValue, double incrementValue) { assert assigned < mask + 1; if (containsKey(key)) { putValue = get(key); putValue = (double) (((putValue) + (incrementValue))); } put(key, putValue); return putValue; }