Entry point for mutable map dsl.
@param map subject
@param nodeClass map class
@return operator
1587
public static MapOperator with(final Map map, final Class<? extends Map> nodeClass) {
        return new MapOperator(map, nodeClass);
    }
352860
public static <K, V> Map<K, V> asDeepTierMap(Map<K, V> map) {
        return from(map).deepLook().tierKey().map();
    }
1209411
public static <K, V> Map<K, V> toImmutableMap(final Map<K, V> map) {
    switch (map.size()) {
      case 0:
        return Collections.emptyMap();
      case 1:
        final Entry<K, V> entry = map.entrySet().iterator().next();
        return Collections.singletonMap(entry.getKey(), entry.getValue());
      default:
        return Collections.unmodifiableMap(map);
    }
  }
1045429
@SuppressWarnings("unchecked")
	@Override
	public <O> Option<O> map(Function<? super T, ? extends O> mapper) {
		return (Option<O>) INSTANCE;
	}
472726
Map<Integer, Pair<Integer, Integer>> constructRingMap(Map<Integer, List<Integer>> treeMap,
                                                                  Map<Integer, Integer> parentMap) {
        assert parentMap.get(0) == -1;

        List<Integer> sharedRing = constructShareRing(treeMap, parentMap, 0);
        assert sharedRing.size() == treeMap.size();

        Map<Integer, Pair<Integer, Integer>> ringMap = new LinkedHashMap<>(numWorkers);
        for(int r = 0; r < numWorkers; r++) {
            int rPrev = (r + numWorkers - 1) % numWorkers;
            int rNext = (r + 1) % numWorkers;
            ringMap.put(sharedRing.get(r), new Pair<>(sharedRing.get(rPrev), sharedRing.get(rNext)));
        }
        return ringMap;
    }
687105
public static <T> Optional<T> get(final Map map, final Class<T> clazz, final Object... path) {
        if (path == null || path.length == 0) {
            throw new IllegalArgumentException(PATH_MUST_BE_SPECIFIED);
        }
        if (path.length == 1) {
            return Optional.ofNullable((T) map.get(path[0]));
        }
        final Object[] pathToLastNode = Arrays.copyOfRange(path, 0, path.length - 1);
        final Object lastKey = path[path.length - 1];
        Map<Object, Object> intermediateMap = map;
        for (Object key : pathToLastNode) {
            final Object node = intermediateMap.get(key);
            if (node != null) {
                final Optional<Map> nodeMapOption = ClassApi.cast(node, Map.class);
                if (nodeMapOption.isPresent()) {
                    intermediateMap = nodeMapOption.get();
                } else {
                    throw new IllegalAccessError("Node with key '" + key + "' is not a map!");
                }
            } else {
                return Optional.empty();
            }
        }
        return Optional.ofNullable((T) intermediateMap.get(lastKey));
    }
797348
public static <K, V> MapBuilder<K, V> builder(Map<K, V> map) {
		return new MapBuilder<>(map);
	}
541663
void buildMapEntry(LinkedHashMap<Object, Expr> map) {
		Expr keyExpr = expr();
		Object key;
		if (keyExpr instanceof Id) {
			key = ((Id)keyExpr).getId();
		} else if (keyExpr instanceof Const) {
			key = ((Const)keyExpr).getValue();
		} else {
			throw new ParseException("Expression error: the value of map key must be identifier, String, Boolean, null or Number", location);
		}
		
		match(Sym.COLON);
		Expr value = expr();
		if (value == null) {
			throw new ParseException("Expression error: the value on the right side of map entry can not be blank", location);
		}
		map.put(key, value);
	}
1306301
private void convertNode(final GraphObjectMap map, final Node node) {

		final NodeList nodeList = node.getChildNodes();
		if (nodeList != null) {

			final List<GraphObjectMap> children = new LinkedList<>();
			final int length                    = nodeList.getLength();

			for (int i=0; i<length; i++) {

				final GraphObjectMap childMap = new GraphObjectMap();
				final Node childNode          = nodeList.item(i);

				convertNode(childMap, childNode);
				children.add(childMap);
			}

			map.put(childrenProperty, children);
		}

		final NamedNodeMap attributeList = node.getAttributes();
		if (attributeList != null) {

			final List<GraphObjectMap> attributes = new LinkedList<>();
			final int length                      = attributeList.getLength();

			for (int i=0; i<length; i++) {

				final GraphObjectMap attributeMap = new GraphObjectMap();
				final Node attributeNode          = attributeList.item(i);

				convertNode(attributeMap, attributeNode);
				attributes.add(attributeMap);
			}

			map.put(attributesProperty, attributes);
		}

		map.put(typeProperty, node.getClass().getSimpleName());

		final String nodeName = node.getNodeName();
		if (nodeName != null) {

			map.put(nameProperty, nodeName);
		}

		final String nodeValue = node.getNodeValue();
		if (nodeValue != null) {

			map.put(valueProperty, nodeValue);
		}
	}
1240360
public static <K extends Comparable<K>, V> Map<K, V> sort(Map<K, V> map) {
        return new TreeMap<>(map);
    }
371570
public <K, V> Map<K, V> map(String name, Class<K> ktype, Class<V> vtype) {
        Map<K, V> map = getNamedObject(name);
        if (map == null) putNamedObject(name, map = new HashMap<K, V>());
        return map;
    }
929297
function mapNode(visitor) {
  const nodeMapper = node => {
    if (node == null) {
      return node;
    }

    const mappingFunction = (() => {
      if ('*' in visitor && typeof visitor['*'] === 'function') {
        return visitor['*'];
      }

      if (node.Type in visitor && typeof visitor[node.Type] === 'function') {
        return visitor[node.Type];
      }
      return identity;
    })();

    if (mappingFunction.length === 2) {
      return mappingFunction(node, nodeMapper);
    }

    const mappedNode = mappingFunction(node);
    const params = mappedNode.params.map(nodeMapper);

    return extend(mappedNode, { params });
  };

  return nodeMapper;
}
288872
private Object newMap(Object obj, Element node) throws Exception {
		String id = getAttribute(node, "id");

		Map<Object, Object> map = new HashMap<>();
		if (id != null) {
			_idMap.put(id, map);
		}

		Element[] children = getChildren(node);
		for (int i = 0; i < children.length; i++) {

			Element element = children[i];

			if (!element.getTagName().equals("Entry")) {
				throw new IllegalStateException("Not an Entry");
			}

			Element key = null;
			Element value = null;

			Element[] entries = getChildren(element);
			for (int j = 0; j < entries.length; j++) {
				Element item = entries[j];
				if (!item.getTagName().equals("Item")) {
					throw new IllegalStateException("Not an Item");
				}
				if (key == null) {
					key = item;
				} else {
					value = item;
				}
			}

			if (key == null || value == null) {
				throw new IllegalStateException("Missing Item in Entry");
			}
			String kid = getAttribute(key, "id");
			String vid = getAttribute(value, "id");

			Object k = value(obj, key);
			Object v = value(obj, value);
			map.put(k, v);

			if (kid != null) {
				_idMap.put(kid, k);
			}
			if (vid != null) {
				_idMap.put(vid, v);
			}
		}

		return map;
	}
1211194
public <K, V> Map<K, V> asMap(@NonNull Class<?> mapClass, @NonNull Class<K> keyClass, @NonNull Class<V> valueClass) {
      return convert(toConvert, mapClass, keyClass, valueClass);
   }
878034
public static void addTypeMapper(Class<?> clz, Class<?> mapper) {
		synchronized (classMapper) {
			LinkedHashSet<Class<?>> h = classMapper.get(clz);
			if (h == null) {
				h = new LinkedHashSet<Class<?>>();
				classMapper.put(clz, h);
			}
			
			h.add(mapper);
		}
	}
732041
public static void extractPlaceholders(ClassNode node, Map<GenericsTypeName, GenericsType> map) {
        if (node == null) return;

        if (node.isArray()) {
            extractPlaceholders(node.getComponentType(), map);
            return;
        }

        if (!node.isUsingGenerics() || !node.isRedirectNode()) return;
        GenericsType[] parameterized = node.getGenericsTypes();
        if (parameterized == null || parameterized.length == 0) return;
        GenericsType[] redirectGenericsTypes = node.redirect().getGenericsTypes();
        if (redirectGenericsTypes == null ||
                (node.isGenericsPlaceHolder() && redirectGenericsTypes.length != parameterized.length) /* GROOVY-8609 */ ) {
            redirectGenericsTypes = parameterized;
        }
        if (redirectGenericsTypes.length != parameterized.length) {
            throw new GroovyBugError("Expected earlier checking to detect generics parameter arity mismatch" +
                    "\nExpected: " + node.getName() + toGenericTypesString(redirectGenericsTypes) +
                    "\nSupplied: " + node.getName() + toGenericTypesString(parameterized));
        }

        List<GenericsType> valueList = new LinkedList<>();
        for (int i = 0; i < redirectGenericsTypes.length; i++) {
            GenericsType redirectType = redirectGenericsTypes[i];
            if (redirectType.isPlaceholder()) {
                GenericsTypeName name = new GenericsTypeName(redirectType.getName());
                if (!map.containsKey(name)) {
                    GenericsType value = parameterized[i];
                    map.put(name, value);

                    valueList.add(value);
                }
            }
        }

        for (GenericsType value : valueList) {
            if (value.isWildcard()) {
                ClassNode lowerBound = value.getLowerBound();
                if (lowerBound != null) {
                    extractPlaceholders(lowerBound, map);
                }
                ClassNode[] upperBounds = value.getUpperBounds();
                if (upperBounds != null) {
                    for (ClassNode upperBound : upperBounds) {
                        extractPlaceholders(upperBound, map);
                    }
                }
            } else if (!value.isPlaceholder()) {
                extractPlaceholders(value.getType(), map);
            }
        }
    }
744409
public static <K, V, M extends Map<K, V>> UnmodifiableMutableMap<K, V> of(M map)
    {
        if (map == null)
        {
            throw new IllegalArgumentException("cannot create a UnmodifiableMutableMap for null");
        }
        return new UnmodifiableMutableMap<K, V>(MapAdapter.adapt(map));
    }