private QueryStatement[] InitBuildNode(ArrayList statements, Hashtable setVars) { // Get the best statements to consider // Because we can consider statements in groups, we need // a list of lists. QueryStatementComparer comparer = new QueryStatementComparer(setVars, fps, ifps); ArrayList considerations = new ArrayList(); for (int i = 0; i < statements.Count; i++) { QueryStatement next = (QueryStatement)statements[i]; int comp = 1; if (considerations.Count > 0) { QueryStatement curcomp = (QueryStatement)((ArrayList)considerations[0])[0]; comp = comparer.Compare(curcomp, next); } if (comp < 0) // next is worse than current { continue; } if (comp > 0) // clear out worse possibilities { considerations.Clear(); } ArrayList group = new ArrayList(); group.Add(next); considerations.Add(group); } // Pick the group with the most number of statements. ArrayList bestgroup = null; foreach (ArrayList g in considerations) { if (bestgroup == null || bestgroup.Count < g.Count) { bestgroup = g; } } foreach (QueryStatement qs in bestgroup) { statements.Remove(qs); } return((QueryStatement[])bestgroup.ToArray(typeof(QueryStatement))); }
private QueryStatement[] InitBuildNode(ArrayList statements, Hashtable setVars) { // Get the best statements to consider // Because we can consider statements in groups, we need // a list of lists. QueryStatementComparer comparer = new QueryStatementComparer(setVars, fps, ifps); ArrayList considerations = new ArrayList(); for (int i = 0; i < statements.Count; i++) { QueryStatement next = (QueryStatement)statements[i]; int comp = 1; if (considerations.Count > 0) { QueryStatement curcomp = (QueryStatement) ((ArrayList)considerations[0])[0]; comp = comparer.Compare(curcomp, next); } if (comp < 0) // next is worse than current continue; if (comp > 0) // clear out worse possibilities considerations.Clear(); ArrayList group = new ArrayList(); group.Add(next); considerations.Add(group); } // Pick the group with the most number of statements. ArrayList bestgroup = null; foreach (ArrayList g in considerations) { if (bestgroup == null || bestgroup.Count < g.Count) bestgroup = g; } foreach (QueryStatement qs in bestgroup) statements.Remove(qs); return (QueryStatement[])bestgroup.ToArray(typeof(QueryStatement)); }