using System;
using edu.neu.ccs.demeterf.lib;

public class LibTest{
    static void p(String s){ Console.WriteLine(s); }

    class M : List<String>.Map<String>{
        public override String map(String s){ return ":"+s; } 
    }

    public static void Main(String[] args){
        p("\n MAP -------------------");
        if(true){
            Map<int,String> m = Map<int,String>.create(List<int>.create(1,3,2,4,2),
                                                       List<String>.create("one","three","two","four","toooo"));
            Map<int,String> m2 = Map<int,String>.create(List<int>.create(1,2,3,4,2),
                                                        List<String>.create("one","two","three","four","toooo"));
            
            p("Map: "+m);
            p("Map: "+m.transformValues(new M()));
            p(" Equals: "+m.Equals(m2));
            p(" Equals: "+m2.Equals(m));
            p(" List: "+m.toList());
            p(" List: "+m2.toList());
            p(" HashCode: "+m.GetHashCode()+" == "+m2.GetHashCode());
            p(" List: "+m2.toList());
            p(" Put: "+m.put(2,"222222"));
            p(" Put: "+m.put(10,"ten"));
            p(" Get: "+m.get(4));
        }

        p("\n SET -------------------");
        if(true){
            Set<int> s1 = Set<int>.create(1,3,5,3,7,5,4,9);
            Set<int> s2 = Set<int>.create(1,4,3,9,5);
        
            p(" 1: "+s1);
            p(" 2: "+s2);
            p(" == false: "+s2.Equals(s1));
            p(" == false: "+s1.Equals(s2));
            p(" == true: "+s2.intersect(s1).Equals(s2));
            p("  Hash: "+s1.GetHashCode());
            p("  Hash: "+s2.GetHashCode());
            p(" Union: "+s1.union(s2));
            p(" Inter: "+s1.intersect(s2));
            p("  Diff: "+s1.difference(s2));
        }


        p("\n LISTMAP -------------------");
        if(true){
            ListMap<int,String> m = ListMap<int,String>.create(List<int>.create(1,3,2,4,2),
                                                           List<String>.create("one","three","two","four","toooo"));
            ListMap<int,String> m2 = ListMap<int,String>.create(List<int>.create(1,2,3,4,5,6,2,7,8),
                                                            List<String>.create("one","two","three","four","toooo"));
            
            p("ListMap: "+m);
            p("ListMap: "+m.transformValues(new M()));
            p(" Equals true: "+m.Equals(m2));
            p(" Equals true: "+m2.Equals(m));
            p(" List: "+m.toList());
            p(" List: "+m2.toList());
            p(" HashCode: "+m.GetHashCode()+" == "+m2.GetHashCode());
            p(" Put: "+m.put(2,"222222"));
            p(" Put: "+m.put(10,"ten"));
            p(" Get: "+m.get(4));
        }

        p("\n LISTSET -------------------");
        if(true){
            ListSet<int> s1 = ListSet<int>.create(1,3,5,3,7,5,4,9);
            ListSet<int> s2 = ListSet<int>.create(1,4,3,9,5);
            
            p(" 1: "+s1);
            p(" 2: "+s2);
            p(" == false: "+s2.Equals(s1));
            p(" == false: "+s1.Equals(s2));
            p(" == true: "+s2.intersect(s1).Equals(s2));
            p("  Hash: "+s1.GetHashCode());
            p("  Hash: "+s2.GetHashCode());
            p(" Union: "+s1.union(s2));
            p(" Inter: "+s1.intersect(s2));
            p("  Diff: "+s1.difference(s2));
        }
    }
}