import edu.neu.ccs.demeterf.lib.*;

/** A quick test of the new "imperative" demfgen.lib.List Methods */
public class ListMapTest extends ListTest{
    java.util.Random r = new java.util.Random();
    public static void main(String[] args){
        new ListMapTest().main();
    }

    void main(){
        if(true){
            Map<Integer,String> m = Map.create(List.create(1,3,2,4,2),
                    List.create("one","three","two","four","toooo"));
            Map<Integer,String> m2 = Map.create(List.create(1,2,3,4,2),
                    List.create("one","two","three","four","toooo"));

            p("Map: "+m);
            p("Map: "+m.transformValues(new List.Map<String, String>(){
                public String map(String s){ return ":"+s; } 
            }).toString());
            p(" Equals: "+m.equals(m2));
            p(" List: "+m.toList());
            p(" List: "+m2.toList());
            p(" HashCode: "+m.hashCode()+" == "+m2.hashCode());
            p(" Get: "+m2.get(2));
            p(" Put: "+m2.put(2, "temp"));
            p(" Put: "+m2.put(10, "temp"));
            p(" Remap: "+m2.remap(2, "temp"));
            p("");
        }
        
        if(true){
            ListMap<Integer,String> m = ListMap.create(List.create(1,3,2,4,2),
                    List.create("one","three","two","four","toooo"));
            ListMap<Integer,String> m2 = ListMap.create(List.create(1,2,3,4,2),
                    List.create("one","two","three","four","toooo"));

            p("ListMap: "+m);
            p("ListMap: "+m.transformValues(new List.Map<String, String>(){
                public String map(String s){ return ":"+s; } 
            }).toString());
            p(" Equals: "+m.equals(m2));
            p(" List: "+m.toList());
            p(" List: "+m2.toList());
            p(" HashCode: "+m.hashCode()+" == "+m2.hashCode());
            p(" Get: "+m2.get(2));
            p(" Put: "+m2.put(2, "temp"));
            p(" Put: "+m2.put(10, "temp"));
            p(" Remap: "+m2.remap(2, "temp"));
            p("");
        }
        
        if(true){
            ListSet<Integer> s1 = ListSet.create(1,3,5,3,7,5,4,9);
            ListSet<Integer> s2 = ListSet.create(1,4,3,9,5);
            
            p(" 1: "+s1);
            p(" 2: "+s2);
            p(" ==: "+s2.equals(s1));
            p(" ==: "+s1.equals(s2));
            p(" ==: "+s2.intersect(s1).equals(s2));
            p("  Hash: "+s1.hashCode());
            p("  Hash: "+s2.hashCode());
            p(" Union: "+s1.union(s2));
            p(" Inter: "+s1.intersect(s2));
            p("  Diff: "+s1.difference(s2));
            p("");
        }
    }
}