// *sigh* this is tediously verbose public BagAnagrams(Bag b, strings words) { this.b = b; this.words = words; }
public static anagrams anagrams(Bag bag, List <BagAnagrams> dictionary, uint recursion_level, bottom_of_main_loop bottom, done_pruning done_pruning_callback, found_anagram success_callback) { anagrams rv = new anagrams(); List <BagAnagrams> pruned = Prune(bag, dictionary, done_pruning_callback, recursion_level); int pruned_initial_size = pruned.Count; while (pruned.Count > 0) { BagAnagrams entry = pruned[0]; Bag this_bag = entry.b; Bag diff = bag.subtract(this_bag); if (diff != null) { if (diff.empty()) { foreach (string w in entry.words) { strings loner = new strings(); loner.Add(w); rv.Add(loner); if (recursion_level == 0) { success_callback(loner); } } } else { anagrams from_smaller = anagrams(diff, pruned, recursion_level + 1, bottom, done_pruning_callback, success_callback); anagrams combined = Combine(entry.words, from_smaller); foreach (strings an in combined) { rv.Add(an); if (recursion_level == 0) { success_callback(an); } } } } pruned.RemoveAt(0); if (recursion_level == 0) { bottom(); } Application.DoEvents(); } return(rv); }
// *sigh* this is tediously verbose public bag_and_anagrams(Bag b, strings words) { this.b = b; this.words = words; }