// C5 example // 2004-09-01 using System; using C5; using SCG = System.Collections.Generic; class MyTest { static readonly IHasher> sequencedTreeBagHasher = new C5.HasherBuilder.SequencedHasher,char>(); static readonly IHasher> unsequencedTreeBagHasher = new C5.HasherBuilder.UnsequencedHasher,char>(); static readonly IHasher> unsequencedHashBagHasher = new C5.HasherBuilder.UnsequencedHasher,char>(); public static void Main(String[] args) { } public static void FindCollisions(SCG.IEnumerable ss) { HashBag occurrences = new HashBag(); foreach (String s in ss) { TreeBag tb = TreeBag(s); // HashBag hb = HashBag(s); occurrences.Add(sequencedTreeBagHasher.GetHashCode(tb)); // unsequencedTreeBagHasher.GetHashCode(tb); // unsequencedHashBagHasher.GetHashCode(hb); } } public static TreeBag TreeBag(String s) { TreeBag anagram = new TreeBag(); foreach (char c in s) anagram.Add(c); return anagram; } public static HashBag HashBag(String s) { HashBag anagram = new HashBag(); foreach (char c in s) anagram.Add(c); return anagram; } }