package swift.utils;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public final class PrettyPrint {
    private PrettyPrint() {
    }

    public static <K> String printSet(String start, String end, String sep, Set<K> elems) {
        StringBuffer buf = new StringBuffer();
        buf.append(start);
        Iterator<K> it = elems.iterator();
        while (it.hasNext()) {
            K e = it.next();
            buf.append(e);
            if (it.hasNext()) {
                buf.append(sep);
            }
        }
        buf.append(end);
        return buf.toString();
    }

    public static <K, V> String printMap(String start, String end, String sep, String map, Map<K, V> elems) {
        StringBuffer buf = new StringBuffer();
        buf.append(start);
        Iterator<Entry<K, V>> it = elems.entrySet().iterator();
        while (it.hasNext()) {
            Entry<K, V> e = it.next();
            buf.append(e.getKey());
            buf.append(" -> ");
            buf.append(e.getValue());
            if (it.hasNext()) {
                buf.append("; ");
            }
        }
        buf.append(" }");
        return buf.toString();
    }
}

@@ -15,16 +15,45 @@
 utils;%0A%0A
+import java.util.Collection;%0A
 import j
@@ -124,30 +124,8 @@
 try;
-%0Aimport java.util.Set;
 %0A%0Apu
@@ -210,16 +210,19 @@
 tatic %3CK
+, V
 %3E String
@@ -227,19 +227,19 @@
 ng print
-Set
+Map
 (String 
@@ -274,12 +274,27 @@
 p, S
-et%3CK
+tring map, Map%3CK, V
 %3E el
@@ -391,17 +391,27 @@
 terator%3C
-K
+Entry%3CK, V%3E
 %3E it = e
@@ -415,16 +415,27 @@
 = elems.
+entrySet().
 iterator
@@ -481,17 +481,27 @@
         
-K
+Entry%3CK, V%3E
  e = it.
@@ -532,16 +532,92 @@
 append(e
+.getKey());%0A            buf.append(map);%0A            buf.append(e.getValue()
 );%0A     
@@ -792,35 +792,42 @@
  V%3E String print
-Map
+Collection
 (String start, S
@@ -849,35 +849,27 @@
 ng sep, 
-String map, Map%3CK, 
+Collection%3C
 V%3E elems
@@ -959,35 +959,25 @@
    Iterator%3C
-Entry%3CK, V%3E
+V
 %3E it = elems
@@ -973,35 +973,24 @@
  it = elems.
-entrySet().
 iterator();%0A
@@ -1028,35 +1028,25 @@
             
-Entry%3CK, V%3E
+V
  e = it.next
@@ -1077,87 +1077,8 @@
 nd(e
-.getKey());%0A            buf.append(%22 -%3E %22);%0A            buf.append(e.getValue()
 );%0A 
@@ -1139,12 +1139,11 @@
 end(
-%22; %22
+sep
 );%0A 
@@ -1188,12 +1188,11 @@
 end(
-%22 %7D%22
+end
 );%0A 

Fix in PrettyPrint util class. Now more general, as it accepts collections (not only sets).