using System; using edu.neu.ccs.demeterf.lib; public class LibTest{ static void p(String s){ Console.WriteLine(s); } class M : List.Map{ public override String map(String s){ return ":"+s; } } public static void Main(String[] args){ p("\n MAP -------------------"); if(true){ Map m = Map.create(List.create(1,3,2,4,2), List.create("one","three","two","four","toooo")); Map 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 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 s1 = Set.create(1,3,5,3,7,5,4,9); Set s2 = Set.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 m = ListMap.create(List.create(1,3,2,4,2), List.create("one","three","two","four","toooo")); ListMap m2 = ListMap.create(List.create(1,2,3,4,5,6,2,7,8), List.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 s1 = ListSet.create(1,3,5,3,7,5,4,9); ListSet s2 = ListSet.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)); } } }