import java.util.*;
public class Main {
// http://e...content-available-to-author-only...c.de/congress/2011/Fahrplan/events/4680.en.html
public static void main
(String[] args
) { final String[] tbl1
= {"ab",
"cd",
"ef"}; final String[] tbl2
= {"tt",
"uU",
"v6"}; final int N = 40000;
for (int i = 0; i < N; i++) {
k1[i] = v[i].replaceAll("0", tbl1[0]).replaceAll("1", tbl1[1]).replaceAll("2", tbl1[2]);
k2[i] = v[i].replaceAll("0", tbl2[0]).replaceAll("1", tbl2[1]).replaceAll("2", tbl2[2]);
}
System.
out.
printf("TreeMap tbl1: %d ms\n", time
(new TreeMap
<String, String
>(), k1, v
)); System.
out.
printf("TreeMap tbl2: %d ms\n", time
(new TreeMap
<String, String
>(), k2, v
)); System.
out.
printf("HashMap tbl1: %d ms\n", time
(new HashMap
<String, String
>(), k1, v
)); System.
out.
printf("HashMap tbl2: %d ms\n", time
(new HashMap
<String, String
>(), k2, v
)); }
int N = k.length;
long begin
= System.
currentTimeMillis(); for (int i = 0; i < N; i++) {
m.put(k[i], v[i]);
}
long end
= System.
currentTimeMillis(); return end - begin;
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKcHVibGljIGNsYXNzIE1haW4gewogIC8vIGh0dHA6Ly9lLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5jLmRlL2NvbmdyZXNzLzIwMTEvRmFocnBsYW4vZXZlbnRzLzQ2ODAuZW4uaHRtbAoKICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICBmaW5hbCBTdHJpbmdbXSB0YmwxID0geyJhYiIsICJjZCIsICJlZiJ9OwogICAgZmluYWwgU3RyaW5nW10gdGJsMiA9IHsidHQiLCAidVUiLCAidjYifTsKICAgIGZpbmFsIGludCBOID0gNDAwMDA7CgogICAgU3RyaW5nW10gazEgPSBuZXcgU3RyaW5nW05dLCBrMiA9IG5ldyBTdHJpbmdbTl07CiAgICBTdHJpbmdbXSB2ID0gbmV3IFN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