package cz.hobrasoft.pdfmu;

import java.util.Arrays;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.regex.Matcher;

/**
 *
 * @author <a href="mailto:filip.bartek@hobrasoft.cz">Filip Bartek</a>
 */
public class PdfmuUtils {

    /**
     * Converts an array of keys and an array of values to a {@link SortedMap}.
     *
     * @param <K> the type of keys.
     * @param <V> the type of values.
     * @param keys the array of keys. Only the keys that have a matching value
     * are used.
     * @param values the array of values. Only the values that have a matching
     * key are used.
     * @return a {@link SortedMap} that contains a key-value pair for each index
     * in keys and values.
     */
    public static <K, V> SortedMap<K, V> sortedMap(K[] keys, V[] values) {
        SortedMap<K, V> result = new TreeMap<>();
        int n = Math.min(keys.length, values.length);
        for (int i = 0; i < n; ++i) {
            result.put(keys[i], values[i]);
        }
        return result;
    }

    public static SortedMap<String, String> getMatcherGroups(Matcher m, String[] names) {
        return getMatcherGroups(m, Arrays.asList(names));
    }

    public static SortedMap<String, String> getMatcherGroups(Matcher m, List<String> names) {
        SortedMap<String, String> result = new TreeMap<>();
        for (String name : names) {
            result.put(name, m.group(name));
        }
        return result;
    }
}

@@ -74,16 +74,39 @@
 .List;%0D%0A
+import java.util.Map;%0D%0A
 import j
@@ -1098,32 +1098,373 @@
 sult;%0D%0A    %7D%0D%0A%0D%0A
+    public static %3CK, V%3E SortedMap%3CK, V%3E sortedMap(Map.Entry%3CK, V%3E... entries) %7B%0D%0A        SortedMap%3CK, V%3E result = new TreeMap%3C%3E();%0D%0A        for (Map.Entry%3CK, V%3E entry : entries) %7B%0D%0A            K key = entry.getKey();%0D%0A            V value = entry.getValue();%0D%0A            result.put(key, value);%0D%0A        %7D%0D%0A        return result;%0D%0A    %7D%0D%0A%0D%0A
     public stati

Add an overload of `sortedMap` that takes an array of entries