/// <summary> /// Create a new intersection set. /// </summary> /// <param name="a"></param> /// <param name="b"></param> public IntersectionSet(IReadonlyObservableSet <T> a, IReadonlyObservableSet <T> b) { _a = a; _b = b; _added = new ObserverSet <Action <T> >(); _removed = new ObserverSet <Action <T> >(); _count = 0; foreach (var item in a) { if (b.Contains(item)) { _count++; } } _aAddedObserver = a.AddedWeak(AddedToA); _aRemovedObserver = a.RemovedWeak(RemovedFromA); _bAddedObserver = b.AddedWeak(AddedToB); _bRemovedObserver = b.RemovedWeak(RemovedFromB); }
public SetProxy(IReadonlyObservableSet <T> target) : this() { Target = target; }
/// <summary> /// Add an removed event handler and remove it, when the disposable is disposed. /// </summary> /// <param name="set"></param> /// <param name="dispose"></param> /// <param name="action"></param> /// <typeparam name="T"></typeparam> public static void Removed <T>(this IReadonlyObservableSet <T> set, Disposable dispose, Action <T> action) { dispose.Add(set.Removed(action)); }
/// <summary> /// Create a new sub set with the specified super set. /// </summary> /// <param name="super"></param> public SubSet(IReadonlyObservableSet <T> super) { _super = super; _superObserver = super.RemovedWeak(item => Remove(item)); }