/// <inheritdoc cref="Do(AListOperation, T)"/> public int Do(AListOperation mode, T item) { AListSingleOperation <T, T> op = new AListSingleOperation <T, T>(); op.Mode = mode; op.CompareKeys = _compareItems; op.CompareToKey = _compareItems; op.Key = op.Item = item; return(DoSingleOperation(ref op)); }
/// <summary>Performs the same operation for each item in a series. /// Equivalent to calling <see cref="Do(AListOperation,T)"/> on each item.</summary> /// <param name="mode">Indicates the operation to perform.</param> /// <param name="e">A list of items to act upon.</param> /// <returns>Returns the change in Count: positive if items were added, /// negative if items were removed, and 0 if all items were unchanged or /// replaced.</returns> public int DoRange(AListOperation mode, IEnumerable <T> e) { AListSingleOperation <T, T> op = new AListSingleOperation <T, T>(); op.Mode = mode; op.CompareKeys = _compareItems; op.CompareToKey = _compareItems; int delta = 0; foreach (T item in e) { op.Key = op.Item = item; // Some fields must be cleared before each operation op.BaseIndex = 0; op.Found = false; op.AggregateChanged = 0; delta += DoSingleOperation(ref op); Debug.Assert(op.Mode == mode); } return(delta); }