Creates a clone of `map`.

@private
@param {Object} map The map to clone.
@param {Function} cloneFunc The function to clone values.
@param {boolean} [isDeep] Specify a deep clone.
@returns {Object} Returns the cloned map.
500361
function cloneMap$1(map, isDeep, cloneFunc) {
  var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG$2) : mapToArray(map);
  return arrayReduce(array, addMapEntry, new map.constructor());
}
64521
@Inline(value="$2.$3copyOf($1)", imported=ImmutableMap.class)
	public static <K, V> Map<K, V> immutableCopy(Map<? extends K, ? extends V> map) {
		return ImmutableMap.copyOf(map);
	}
638614
function cloneItree(itree, excludeKeys) {
    const clone = {};
    excludeKeys = _.castArray(excludeKeys);
    excludeKeys.push('ref');

    _.each(itree, (v, k) => {
        if (!_.includes(excludeKeys, k)) {
            clone[k] = _.cloneDeep(v);
        }
    });

    return clone;
}
379255
function cloneIt2(o) {
	let keys = Object.keys(o);
	let current = o;
	const acc = {};
	let currentAcc = acc;

	let i = 0;
	let iMax = keys.length + 1;
	let previous = [];
	let activeKey = [];

	for (; i < iMax; i++) {
		if (i === iMax - 1) {
			if (!previous.length) {
				break;
			}

			const prev = previous.pop();
			activeKey.pop();

			i = prev.i;
			iMax = prev.iMax;
			keys = prev.keys;

			let j = 0;
			const jMax = activeKey.length;
			currentAcc = acc;
			current = o;

			for (; j < jMax; j++) {
				currentAcc = currentAcc[activeKey[j]];
				current = current[activeKey[j]];
			}
		} else if (typeof current[keys[i]] === 'object') {
			currentAcc[keys[i]] = {};

			previous.push({ i, iMax, keys });
			activeKey.push(keys[i]);
			current = current[keys[i]];
			currentAcc = currentAcc[keys[i]];
			i = -1;
			keys = Object.keys(current);
			iMax = keys.length + 1;
		} else {
			currentAcc[keys[i]] = current[keys[i]];
		}
	}

	return acc;
}
15714
function clone(collection, deep = true) {
		const clones = new Jamon();

		collection.forEach(element => clones.push(element.cloneNode(deep)));

		return clones;
	}
1261616
public static <K, V> Map<K, V> updateMap(final Map<K, V> original, MapDifference<K, V> diff) throws MergeException {
        Map<K, V> result = new HashMap<K, V>(original);
        if (diff.areEqual()) {
            return result;
        }
        for (Entry<K, V> entry : diff.entriesOnlyOnLeft().entrySet()) {
            V originalValue = original.get(entry.getKey());
            if (ObjectUtils.equals(originalValue, entry.getValue())) {
                result.remove(entry.getKey());
            }
        }
        for (Entry<K, V> entry : diff.entriesOnlyOnRight().entrySet()) {
            K key = entry.getKey();
            if (original.containsKey(key)) {
                if (ObjectUtils.notEqual(original.get(key), entry.getValue())) {
                    throw new MergeException(String.format(
                        "tried to introduce a new value, but it was already there: %s (%s,%s)",
                        key, original.get(key), entry.getValue()));
                }
            }
            result.put(entry.getKey(), entry.getValue());
        }
        for (Entry<K, ValueDifference<V>> entry : diff.entriesDiffering().entrySet()) {
            K key = entry.getKey();
            V originalValue = original.get(entry.getKey());
            if (ObjectUtils.equals(originalValue, entry.getValue().leftValue())) {
                // Map changed in diff only
                result.put(key, entry.getValue().rightValue());
            } else if (ObjectUtils.equals(originalValue, entry.getValue().rightValue())) {
                // Diff would change value to value already in original Map
                result.put(key, originalValue);
            } else {
                // Merge conflict, got 3 different Values
                String errorMessage =
                    String
                        .format(
                            "Changes could not be applied, because original value differes from left-side of the"
                                    + "MapDifference: %s (%s,%s)", entry.getKey(), original.get(entry.getKey()),
                            entry.getValue());
                throw new MergeException(errorMessage);
            }
        }
        return result;
    }
473414
public static <K, V> MutableMap<V, K> reverseMapping(Map<K, V> map)
    {
        final MutableMap<V, K> reverseMap = UnifiedMap.newMap(map.size());
        MapIterate.forEachKeyValue(map, new Procedure2<K, V>()
        {
            public void value(K sourceKey, V sourceValue)
            {
                reverseMap.put(sourceValue, sourceKey);
            }
        });
        return reverseMap;
    }
1039212
public static <K, KK, VV> Map<KK, VV> getAndPutMapIfAbsent(final Map<K, Map<KK, VV>> map, final K key) {
        Map<KK, VV> v = map.get(key);

        if (v == null) {
            v = new HashMap<>();
            v = map.put(key, v);
        }

        return v;
    }
1037387
public static Map<String, Map<String, String>> merge(
            final Map<String, Map<String, String>> targetContext,
            final Map<String, Map<String, String>> newContext
    )
    {

        final HashMap<String, Map<String, String>> result = deepCopy(targetContext);
        for (final Map.Entry<String, Map<String, String>> entry : newContext.entrySet()) {
            if (!targetContext.containsKey(entry.getKey())) {
                result.put(entry.getKey(), new HashMap<>());
            } else {
                result.put(entry.getKey(), new HashMap<>(targetContext.get(entry.getKey())));
            }
            result.get(entry.getKey()).putAll(entry.getValue());
        }
        return result;
    }
193443
function clone(object, deep) {
		if (!object) { return object; }
		var clone = object.prototype
						? Object.create(object.prototype.constructor) : {};

		for(var key in object) {
			if (!object.hasOwnProperty(key)) { continue; }
			clone[key] = deep ? clone(object[key], deep) : object[key];
		}
		return clone;
	}
719098
public static SoyMap legacyObjectMapToMap(SoyLegacyObjectMap map) {
    Map<SoyValue, SoyValueProvider> newMap = new HashMap<>();
    for (SoyValue key : map.getItemKeys()) {
      newMap.put(key, map.getItemProvider(key));
    }
    return SoyMapImpl.forProviderMap(newMap);
  }
240469
function (map) {
            var didSomething = false;
            _.forEach(map, function (arr, key) {
                // length > 1 means we have duplicates that need to be resolved
                if (arr.length > 1) {
                    arr.forEach(function (index) {
                        if (filePaths[index].length !== 0) {
                            displayPaths[index] = filePaths[index].pop() + "/" + displayPaths[index];
                            didSomething = true;

                            if (!map[displayPaths[index]]) {
                                map[displayPaths[index]] = [index];
                            } else {
                                map[displayPaths[index]].push(index);
                            }
                        }
                    });
                }
                delete map[key];
            });
            return didSomething;
        }
608394
public static <K, V> Map<K, V> copyOf(Map<K, V> map) {
        Preconditions.checkNotNull(map);
        return ImmutableMap.<K, V> builder().putAll(map).build();
    }
225621
function deepClone(value) {
    var accessor,
        circular,
        clone,
        ctor,
        descriptor,
        extensible,
        key,
        length,
        markerKey,
        parent,
        result,
        source,
        subIndex,
        data = { 'value': value },
        index = 0,
        marked = [],
        queue = { 'length': 0 },
        unmarked = [];

    /**
     * An easily detectable decorator for cloned values.
     */
    function Marker(object) {
      this.raw = object;
    }

    /**
     * The callback used by `forProps()`.
     */
    function forPropsCallback(subValue, subKey) {
      // exit early to avoid cloning the marker
      if (subValue && subValue.constructor == Marker) {
        return;
      }
      // add objects to the queue
      if (subValue === Object(subValue)) {
        queue[queue.length++] = { 'key': subKey, 'parent': clone, 'source': value };
      }
      // assign non-objects
      else {
        try {
          // will throw an error in strict mode if the property is read-only
          clone[subKey] = subValue;
        } catch(e) { }
      }
    }

    /**
     * Gets an available marker key for the given object.
     */
    function getMarkerKey(object) {
      // avoid collisions with existing keys
      var result = uid;
      while (object[result] && object[result].constructor != Marker) {
        result += 1;
      }
      return result;
    }

    do {
      key = data.key;
      parent = data.parent;
      source = data.source;
      clone = value = source ? source[key] : data.value;
      accessor = circular = descriptor = false;

      // create a basic clone to filter out functions, DOM elements, and
      // other non `Object` objects
      if (value === Object(value)) {
        // use custom deep clone function if available
        if (isClassOf(value.deepClone, 'Function')) {
          clone = value.deepClone();
        } else {
          ctor = value.constructor;
          switch (toString.call(value)) {
            case '[object Array]':
              clone = new ctor(value.length);
              break;

            case '[object Boolean]':
              clone = new ctor(value == true);
              break;

            case '[object Date]':
              clone = new ctor(+value);
              break;

            case '[object Object]':
              isObject(value) && (clone = new ctor);
              break;

            case '[object Number]':
            case '[object String]':
              clone = new ctor(value);
              break;

            case '[object RegExp]':
              clone = ctor(value.source,
                (value.global     ? 'g' : '') +
                (value.ignoreCase ? 'i' : '') +
                (value.multiline  ? 'm' : ''));
          }
        }
        // continue clone if `value` doesn't have an accessor descriptor
        // http://es5.github.com/#x8.10.1
        if (clone && clone != value &&
            !(descriptor = source && support.descriptors && getDescriptor(source, key),
              accessor = descriptor && (descriptor.get || descriptor.set))) {
          // use an existing clone (circular reference)
          if ((extensible = isExtensible(value))) {
            markerKey = getMarkerKey(value);
            if (value[markerKey]) {
              circular = clone = value[markerKey].raw;
            }
          } else {
            // for frozen/sealed objects
            for (subIndex = 0, length = unmarked.length; subIndex < length; subIndex++) {
              data = unmarked[subIndex];
              if (data.object === value) {
                circular = clone = data.clone;
                break;
              }
            }
          }
          if (!circular) {
            // mark object to allow quickly detecting circular references and tie it to its clone
            if (extensible) {
              value[markerKey] = new Marker(clone);
              marked.push({ 'key': markerKey, 'object': value });
            } else {
              // for frozen/sealed objects
              unmarked.push({ 'clone': clone, 'object': value });
            }
            // iterate over object properties
            forProps(value, forPropsCallback, { 'which': 'all' });
          }
        }
      }
      if (parent) {
        // for custom property descriptors
        if (accessor || (descriptor && !(descriptor.configurable && descriptor.enumerable && descriptor.writable))) {
          if ('value' in descriptor) {
            descriptor.value = clone;
          }
          setDescriptor(parent, key, descriptor);
        }
        // for default property descriptors
        else {
          parent[key] = clone;
        }
      } else {
        result = clone;
      }
    } while ((data = queue[index++]));

    // remove markers
    for (index = 0, length = marked.length; index < length; index++) {
      data = marked[index];
      delete data.object[data.key];
    }
    return result;
  }
462272
public static MapPro duplicateDataMember(ComponentImpl c, MapPro map, MapPro newMap, boolean deepCopy) {
	Iterator it = map.entrySet().iterator();
	Map.Entry entry;
	Object value;
	while (it.hasNext()) {
	    entry = (Entry) it.next();
	    value = entry.getValue();

	    if (!(value instanceof UDF)) {
		if (deepCopy) value = Duplicator.duplicate(value, deepCopy);
		newMap.put(entry.getKey(), value);
	    }
	}
	return newMap;
    }
1279921
@SuppressWarnings("unchecked")
  public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(
      final MultiValueMap<? extends K, ? extends V> map) {
    Assert.notNull(map, "'map' must not be null");
    final Map<K, List<V>> result = new LinkedHashMap<>(map.size());
    map.forEach((key, value) -> {
      final List<? extends V> values = Collections.unmodifiableList(value);
      result.put(key, (List<V>) values);
    });
    final Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result);
    return CollectionUtils.toMultiValueMap(unmodifiableMap);
  }
1143790
function mapToObject(input, mapFunc) {
    const obj = {};
    for (const element of input) {
        obj[element] = mapFunc(element);
    }
    return obj;
}