Code example for SortedMap

Methods: comparator

0
	 * @see java.util.LinkedHashMap 
	 */ 
	@SuppressWarnings("unchecked") 
	public static <K, V> Map<K, V> createApproximateMap(Object map, int initialCapacity) {
		if (map instanceof SortedMap) {
			return new TreeMap<K, V>(((SortedMap<K, V>) map).comparator());
		} 
		else { 
			return new LinkedHashMap<K, V>(initialCapacity);
		} 
	} 
 
	/** 
	 * Create the most approximate map for the given map. 
	 * <p>Creates a TreeMap or linked Map for a SortedMap or Map, respectively. 
	 * @param mapType the desired type of the target Map 
	 * @param initialCapacity the initial capacity 
	 * @return the new Map instance 
	 * @see java.util.TreeMap 
	 * @see java.util.LinkedHashMap