/** * Intersect(A,Intersect(B,C)) -> Intersect(A,B,C) * If any of the sources of the intersection are also intersections, * collapses their sources into the current intersection. */ private void ExpandIntersections(ArrayList newPredicateList, ref bool optimized) { for (int i = 0; i < _sourcePredicates.Length; i++) { IntersectionPredicate sourceIntersection = _sourcePredicates [i] as IntersectionPredicate; if (sourceIntersection != null) { newPredicateList.AddRange(sourceIntersection._sourcePredicates); optimized = true; } else { newPredicateList.Add(_sourcePredicates [i]); } } }
public IResourceList Intersect(IResourceList other, bool allowMerge) { if (other == null) { return(this); } ResourceList otherList = (ResourceList)other; if (_predicate.Equals(otherList.Predicate)) { Trace.WriteLine("Attempt to intersect lists with equal predicates " + _predicate.ToString()); return(this); } if (allowMerge) { ResourceList destList = this; ResourceList srcList = otherList; IntersectionPredicate predicate = null; if (_list == null) { predicate = _predicate as IntersectionPredicate; } if (predicate == null && otherList._list == null) { srcList = this; destList = otherList; predicate = otherList._predicate as IntersectionPredicate; } if (predicate != null) { predicate.AddSource(srcList.Predicate); return(MergeListData(destList, srcList)); } } IntersectionPredicate pred = new IntersectionPredicate(_predicate, otherList._predicate); ResourceList result = new ResourceList(pred, _isLive || otherList.IsLive); return(MergeListData(result, this, otherList)); }