Exemplo n.º 1
0
        public IEnumerable <IList <int> > EnumerateIntervals(FactsPartsDictionary FactsOfParts, int ix, IList <int> data, bool ensureKeyCount)
        {
            var items = data;

            //CurrentLength = GetDictFilterCount();
            if (ix == 0)
            {
                if (DictFilterIndexes.Count > 0)
                {
                    items = FactsOfParts.SearchFactsIndexByKey(DictFilterIndexes.ToArray(), data);
                }
                foreach (var negativeindex in NegativeDictFilterIndexes)
                {
                    if (FactsOfParts.ContainsKey(negativeindex))
                    {
                        items = Utilities.Objects.SortedExcept(items, FactsOfParts[negativeindex]);
                    }
                }
            }

            if (Pools.Count == 0)
            {
                yield return(items);

                yield break;
            }

            if (ix == Pools.Count)
            {
                yield return(data);
            }
            else
            {
                var currentpool = Pools[ix];

                //if (currentpool.DictFilterIndexes.Count > 0)
                //{
                //    items = FactsOfParts.SearchFactsIndexByKey(currentpool.DictFilterIndexes.ToArray(), items);
                //}
                //foreach (var negativeindex in currentpool.NegativeDictFilterIndexes)
                //{
                //    if (FactsOfParts.ContainsKey(negativeindex))
                //    {
                //        items = Utilities.Objects.SortedExcept(items, FactsOfParts[negativeindex]);
                //    }
                //}
                //if (currentpool.ChildQueries.Count == 0)
                //{
                //    yield return items;
                //}
                foreach (var qry in currentpool.ChildQueries)
                {
                    var subresult = qry.ToIntervalList(FactsOfParts, items);
                    foreach (var x in EnumerateIntervals(FactsOfParts, ix + 1, subresult, ensureKeyCount))
                    {
                        yield return(x);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public IList <int> ToIntervalList(FactsPartsDictionary FactsOfParts, IList <int> facts, bool ensurepartnr = false)
        {
            //cover here
            var items = FactsOfParts.SearchFactsIndexByKey(DictFilterIndexes.ToArray(), facts);

            foreach (var negativeindex in NegativeDictFilterIndexes)
            {
                if (FactsOfParts.ContainsKey(negativeindex))
                {
                    items = Utilities.Objects.SortedExcept(items, FactsOfParts[negativeindex]);
                }
            }
            if (ChildQueries.Count > 0)
            {
                var result = new IntervalList();

                foreach (var childquery in ChildQueries)
                {
                    result.AddRange(childquery.ToIntervalList(FactsOfParts, items));
                }
                return(result);
            }

            return(items);
        }
Exemplo n.º 3
0
        public IEnumerable <FactBaseQueryResult> EnumerateResults(FactsPartsDictionary FactsOfParts, int ix, IList <int> data, FactBaseQuery currentquery, bool skipinitialfiltering = false)
        {
            var items = data;

            //CurrentLength = GetDictFilterCount();
            if (ix == 0)
            {
                currentquery = new FactBaseQuery();
                currentquery.DictFilterIndexes = this.DictFilterIndexes;
                if (DictFilterIndexes.Count > 0 && !skipinitialfiltering)
                {
                    items = FactsOfParts.SearchFactsIndexByKey(DictFilterIndexes.ToArray(), data);
                }
                foreach (var negativeindex in NegativeDictFilterIndexes)
                {
                    if (FactsOfParts.ContainsKey(negativeindex))
                    {
                        items = Utilities.Objects.SortedExcept(items, FactsOfParts[negativeindex]);
                    }
                }
            }

            if (Pools.Count == 0)
            {
                var result = new FactBaseQueryResult();
                result.Items = items;
                result.Query = currentquery;
                yield return(result);

                yield break;
            }

            if (ix == Pools.Count)
            {
                var result = new FactBaseQueryResult();
                result.Items = data;
                result.Query = currentquery;
                yield return(result);
            }
            else
            {
                foreach (var qry in Pools[ix].ChildQueries)
                {
                    var subresult = qry.ToIntervalList(FactsOfParts, items);
                    var subquery  = new FactBaseQuery();
                    FactBaseQuery.BaseMerge(currentquery, subquery);
                    FactBaseQuery.BaseMerge(qry, subquery);
                    foreach (var x in EnumerateResults(FactsOfParts, ix + 1, subresult, subquery))
                    {
                        yield return(x);
                    }
                }
            }
        }