コード例 #1
0
        /**
         * Intersect(A, Union(A, B)) -> A
         * Removes from the specified array list union predicates which contain
         * members of the current intersection.
         */

        private void RemoveIntersectingUnions(ArrayList newPredicateList, ref bool optimized)
        {
            for (int i = newPredicateList.Count - 1; i >= 0; i--)
            {
                UnionPredicate sourceUnion = newPredicateList [i] as UnionPredicate;
                if (sourceUnion != null)
                {
                    for (int j = 0; j < newPredicateList.Count; j++)
                    {
                        if (i != j && sourceUnion.ContainsPredicate((ResourceListPredicate)newPredicateList [j]))
                        {
                            newPredicateList.RemoveAt(i);
                            optimized = true;
                            break;
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: ResourceList.cs プロジェクト: mo5h/omeo
        public IResourceList Union(IResourceList other, bool allowMerge)
        {
            if (other == null)
            {
                return(this);
            }

            ResourceList otherList = (ResourceList)other;

            if (allowMerge)
            {
                ResourceList   destList  = this;
                ResourceList   srcList   = otherList;
                UnionPredicate predicate = null;
                if (_list == null)
                {
                    predicate = _predicate as UnionPredicate;
                }
                if (predicate == null && otherList._list == null)
                {
                    srcList   = this;
                    destList  = otherList;
                    predicate = otherList._predicate as UnionPredicate;
                }
                if (predicate != null)
                {
                    predicate.AddSource(srcList.Predicate);
                    return(MergeListData(destList, srcList));
                }
            }

            UnionPredicate pred = new UnionPredicate(_predicate, otherList._predicate);

            ResourceList result = new ResourceList(pred, _isLive || otherList.IsLive);

            return(MergeListData(result, this, otherList));
        }