public MergedResultTableRelations(ResultTableRelations ResultTableRelations)
 {
     OrderQueue  = new Queue <DictionaryNode>();
     VisitedNode = new HashSet <int>();
     VisitedName = new HashSet <string>();
     this.ResultTableRelations = ResultTableRelations;
 }
Example #2
0
        public SelectOutput(string selectParam, DeclarationsArray declarationsArray)
        {
            SuchThat suchThat = new SuchThat(declarationsArray);

            SelectParam = selectParam;

            queryResults = new List <MethodResultList>();
            //validation completed
            foreach (var methodToDo in SuchThatValidator.GetMethodsToDo())
            {
                queryResults.Add(suchThat.DoSuchThatMethod(methodToDo.MethodName, methodToDo.Param1, methodToDo.Param2));
            }

            //foreach (var qr in queryResults)
            //{
            //    Console.WriteLine($"\n{qr.ListType1}\t{qr.ListType2}");
            //    for (int i = 0; i < qr.List1.Count; i++)
            //    {
            //        Console.WriteLine($"{((AbstractAuxiliaryGrammar) qr.List1[i]).entry}\t{((AbstractAuxiliaryGrammar) qr.List2[i]).entry}");
            //    }
            //}


            ResultTableRelations resultTableRelations = new ResultTableRelations();

            for (int i = 0; i < queryResults.Count; i++)
            {
                MethodResultList qr = queryResults[i];

                if (qr.ListType1 == typeof(Ident))
                {
                    if (qr.ListType2 == typeof(Ident))
                    {
                        resultTableRelations.AddRelation(qr.QueryParam1, qr.QueryParam2, i);
                    }
                    else //qr.ListType2 == typeof(Ident)
                    {
                        resultTableRelations.AddRelation(qr.QueryParam1, i);
                    }
                }
                else //qr.ListType1 != typeof(Ident)
                {
                    if (qr.ListType2 == typeof(Ident))
                    {
                        resultTableRelations.AddRelation(qr.QueryParam2, i);
                    }
                    else //qr.ListType2 != typeof(Ident)
                    {
                        resultTableRelations.AddRelation(qr.QueryParam2, qr.QueryParam1, i);
                    }
                }
            }

            MergedResultTableRelations mergedResultTableRelations = new MergedResultTableRelations(resultTableRelations);

            StackList = mergedResultTableRelations.ExecuteAllMerges(selectParam);
        }