/*
 * Copyright (c) 2016 Cinchapi Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.cinchapi.common.collect;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * A collection of functions that efficiently operate on {@link Map maps}.
 * 
 * @author Jeff Nelson
 */
public final class AnyMaps {

    /**
     * Return a <em>mutable</em>, insertion-ordered {@link LinkedHashMap}
     * instance with enough room to fit {@code capacity} items.
     * 
     * <p>
     * Use this method over
     * {@link com.google.common.collect.Maps#newLinkedHashMap()} when the size
     * of the map is known in advance and we are being careful to not oversize
     * collections.
     * </p>
     * 
     * @param capacity the initial capacity
     * @return a new, empty {@link LinkedHashMap}
     */
    public static <K, V> Map<K, V> newLinkedHashMapWithCapacity(int capacity) {
        return new LinkedHashMap<K, V>(capacity);
    }

    /**
     * Rename {@code key} to {@code newKey} within the {@code map} using the
     * concurrency guarantees of the {@code map}'s type.
     * 
     * @param key
     * @param newKey
     * @param map
     */
    public static <T> void rename(String key, String newKey,
            Map<String, T> map) {
        if(map.containsKey(key)) {
            T value = map.get(key);
            if(map.remove(key, value)) {
                map.put(newKey, value);
            }
            else {
                rename(key, newKey, map);
            }
        }
    }

}

@@ -680,19 +680,85 @@
 va.util.
-Map
+List;%0Aimport java.util.Map;%0A%0Aimport com.google.common.primitives.Ints
 ;%0A%0A/**%0A 
@@ -2090,10 +2090,960 @@
 %0A    %7D%0A%0A
+    /**%0A     * Return a possibly nested value in a %7B@link Map%7D that contains other maps%0A     * and collections as values.%0A     * %0A     * @param path a navigable path key (e.g. foo.bar.1.baz)%0A     * @return the value%0A     */%0A    @SuppressWarnings(%22unchecked%22)%0A    public static %3CT%3E T navigate(String path,%0A            Map%3CString, ? extends Object%3E map) %7B%0A        T value = null;%0A        String%5B%5D components = path.split(%22%5C%5C.%22);%0A        Object lookup = map;%0A        for (String component : components) %7B%0A            Integer index;%0A            if(lookup == null) %7B%0A                break;%0A            %7D%0A            else if((index = Ints.tryParse(component)) != null) %7B%0A                lookup = ((List%3C?%3E) lookup).get(index);%0A            %7D%0A            else %7B%0A                lookup = ((Map%3CString, Object%3E) lookup).get(component);%0A            %7D%0A        %7D%0A        if(lookup != null) %7B%0A            value = (T) lookup;%0A        %7D%0A        return value;%0A    %7D%0A%0A
 %7D%0A

add AnyMaps#navigate method