Java Map Put putPairs(Map map, Object... pairs)

Here you can find the source of putPairs(Map map, Object... pairs)

Description

put Pairs

License

Open Source License

Parameter

Parameter Description
pairs A list of Key-value pairs, like [key1,value1,key2,value2,...]

Declaration

@SuppressWarnings("unchecked")
public static <K, V> void putPairs(Map<K, V> map, Object... pairs) 

Method Source Code

//package com.java2s;
/* ***** BEGIN LICENSE BLOCK *****
 *
 * This file is part of Weave.//  w  ww  .  j  ava2  s.com
 *
 * The Initial Developer of Weave is the Institute for Visualization
 * and Perception Research at the University of Massachusetts Lowell.
 * Portions created by the Initial Developer are Copyright (C) 2008-2015
 * the Initial Developer. All Rights Reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 * 
 * ***** END LICENSE BLOCK ***** */

import java.util.Map;

public class Main {
    /**
     * @param pairs A list of Key-value pairs, like [key1,value1,key2,value2,...]
     */
    @SuppressWarnings("unchecked")
    public static <K, V> void putPairs(Map<K, V> map, Object... pairs) {
        for (int i = 1; i < pairs.length; i += 2)
            map.put((K) pairs[i - 1], (V) pairs[i]);
    }
}

Related

  1. putNotDup(Map tbl, String key, String value)
  2. putObject(Map map, V key, W value)
  3. putObjectsInMultiMap(Map>> multiMap, Integer key, List stringPair)
  4. putOrCreateList(Map> map, K key, V value)
  5. putOrRemove(Map map, String key, Object obj)
  6. putParameter(String key, String value, Map map)
  7. putPreferenceStoredMapValue(String keyOfPreference, String keyInMap, Object value)
  8. putRowMap(Map map, String value)
  9. putSafelyMap(Map> pathFeaturesMap, K1 featureDescriptor, K2 pathId, E featureValue)