public void PullDownNamespaces(SCG.IEnumerable <SCG.IEnumerable <string> > Namespaces) { // collect everything into a non lazy structure first var insertions = new SCG.List <SuggestionTree <Pay> .IntermFResult.single_suggestion>(); foreach (var ns in Namespaces) { var namespace_node_res = FindSequence(ns.ToArray(), last_query_is_exact: true); if (namespace_node_res.type == SuggestionTree <Pay> .FRType.unique_fit) { SuggestionTree <Pay> namespaceNode = namespace_node_res.suggs[0].val; foreach (var single_sugg in namespaceNode.FindAllWithPayload()) { insertions.Add(single_sugg); } } else { throw new Exception("no exact match for Namespace-pulling : " + string.Join(".", ns.ToArray())); // <- turn this into consumer catchable Exception as soon as user defined "usings" are a thing } } // second iteration to not intertwine access and modifying - and avoid reasoning headaches foreach (var single_sugg in insertions) { Add(single_sugg.steps, single_sugg.val.payload); // Add overrides the payload } }
public GreenC5UserControl(string greenC5Name, bool infiniteExecution, int k1, double k2) { InitializeComponent(); Status = "Idle"; IsInfiniteMode = infiniteExecution; GreenC5Name = greenC5Name; lbName.Text = "Instance ID: " + GreenC5Name; InternalDataStructure = new GreenC5 <string>(); K1 = k1; K2 = k2; //set datastructure list by groups for validation SCG.List <C5DataStructure> iCollection = new SCG.List <C5DataStructure>(); iCollection.Add(C5DataStructure.ArrayList); iCollection.Add(C5DataStructure.HashBag); iCollection.Add(C5DataStructure.HashedArrayList); iCollection.Add(C5DataStructure.HashedLinkedList); iCollection.Add(C5DataStructure.HashSet); iCollection.Add(C5DataStructure.LinkedList); iCollection.Add(C5DataStructure.SortedArray); iCollection.Add(C5DataStructure.TreeBag); iCollection.Add(C5DataStructure.TreeSet); dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.ICollection, iCollection)); SCG.List <C5DataStructure> iCollectionBag = new SCG.List <C5DataStructure>(); iCollectionBag.Add(C5DataStructure.HashBag); iCollectionBag.Add(C5DataStructure.TreeBag); iCollectionBag.Add(C5DataStructure.ArrayList); iCollectionBag.Add(C5DataStructure.LinkedList); dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.ICollectionBag, iCollectionBag)); SCG.List <C5DataStructure> iCollectionSet = new SCG.List <C5DataStructure>(); iCollectionSet.Add(C5DataStructure.HashSet); iCollectionSet.Add(C5DataStructure.TreeSet); iCollectionSet.Add(C5DataStructure.HashedArrayList); iCollectionSet.Add(C5DataStructure.HashedLinkedList); iCollectionSet.Add(C5DataStructure.SortedArray); dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.ICollectionSet, iCollectionSet)); SCG.List <C5DataStructure> iList = new SCG.List <C5DataStructure>(); iList.Add(C5DataStructure.ArrayList); iList.Add(C5DataStructure.LinkedList); iList.Add(C5DataStructure.HashedArrayList); iList.Add(C5DataStructure.HashedLinkedList); iList.Add(C5DataStructure.SortedArray); dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.IList, iList)); SCG.List <C5DataStructure> iListBag = new SCG.List <C5DataStructure>(); iListBag.Add(C5DataStructure.ArrayList); iListBag.Add(C5DataStructure.LinkedList); dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.IListBag, iListBag)); SCG.List <C5DataStructure> iListSet = new SCG.List <C5DataStructure>(); iListSet.Add(C5DataStructure.HashedArrayList); iListSet.Add(C5DataStructure.HashedLinkedList); iListSet.Add(C5DataStructure.SortedArray); dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.IListSet, iListSet)); //set data structure groups SCG.List <KeyValuePair <DataStructureGroup, C5DataStructure> > dsGroupAndWorstDataStructures = new SCG.List <KeyValuePair <DataStructureGroup, C5DataStructure> >(); dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.ICollection, C5DataStructure.ArrayList)); dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.ICollectionBag, C5DataStructure.LinkedList)); dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.ICollectionSet, C5DataStructure.SortedArray)); dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.IList, C5DataStructure.LinkedList)); dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.IListBag, C5DataStructure.LinkedList)); dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.IListSet, C5DataStructure.SortedArray)); //cbDataStructureGroup.DisplayMember = "Key"; //cbDataStructureGroup.ValueMember = "Value"; cbDataStructureGroup.DataSource = dsGroupAndWorstDataStructures; SCG.List <KeyValuePair <string, string> > crudWorkloadPrograms = new SCG.List <KeyValuePair <string, string> >(); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #1", @"CRUD Workloads\SmallRandomApplication1.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #2", @"CRUD Workloads\SmallRandomApplication2.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #3", @"CRUD Workloads\SmallRandomApplication3.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #4", @"CRUD Workloads\SmallRandomApplication4.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #1", @"CRUD Workloads\RandomApplication1.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #2", @"CRUD Workloads\RandomApplication2.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #3", @"CRUD Workloads\RandomApplication3.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #4", @"CRUD Workloads\RandomApplication4.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #5", @"CRUD Workloads\RandomApplication5.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #6", @"CRUD Workloads\RandomApplication6.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #7", @"CRUD Workloads\RandomApplication7.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #8", @"CRUD Workloads\RandomApplication8.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #9", @"CRUD Workloads\RandomApplication9.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #10", @"CRUD Workloads\RandomApplication10.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Custom", @"CRUD Workloads\AStarPathFinderProgram_Custom_Formula.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Diagnal Shortcut", @"CRUD Workloads\AStarPathFinderProgram_DiagonalShortcut_Formula.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Euclidean", @"CRUD Workloads\AStarPathFinderProgram_Euclidean_Formula.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Manhatan", @"CRUD Workloads\AStarPathFinderProgram_Manhatan_Formula.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Max Dx Dy", @"CRUD Workloads\AStarPathFinderProgram_MaxDXDY_Formula.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Genetic Algorithm - Fitness Table", @"CRUD Workloads\GA-FittnessTableProgram.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Genetic Algorithm - Next Generation", @"CRUD Workloads\GA-NextGenerationProgram.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Genetic Algorithm - This Generation", @"CRUD Workloads\GA-ThisGenerationProgram.csv")); crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Huffman Encoding", @"CRUD Workloads\HuffmanCodingProgram.csv")); cbPrograms.DataSource = new BindingSource(crudWorkloadPrograms, null); cbPrograms.DisplayMember = "Key"; //cbPrograms.ValueMember = "Value"; //set the values to the program potion dropdownlist //set data structure options to a Static Mode selection cbStartDataStructure.DataSource = c5DSs; //Set run mode cbRunMode.DataSource = Enum.GetValues(typeof(DataStructureMode)); cbRunMode.SelectedItem = DataStructureMode.Dynamic; if (cbDataStructureGroup.SelectedItem != null) { KeyValuePair <DataStructureGroup, C5DataStructure> dsg = (KeyValuePair <DataStructureGroup, C5DataStructure>)cbDataStructureGroup.SelectedItem; CurrentDataStructureGroup = dsg.Key; StartDataStructure = dsg.Value; CurrentC5DataStructure = dsg.Value; lbCurrentDataStructure.Text = "Current Data Structure: " + CurrentC5DataStructure.ToString(); cbStartDataStructure.SelectedItem = StartDataStructure; } if (cbPrograms.SelectedItem != null) { CurrentProgram = (KeyValuePair <string, string>)cbPrograms.SelectedItem; } startMode = false; bool ok = LoadProgram(); }