/// <summary> /// Invoke an element-wise action across two arrays. /// </summary> /// <param name="that">An array of the same size as <c>this</c>. Can be the same object as <c>this</c>.</param> /// <param name="action">A delegate which accesses the array cursors.</param> public void ForEach(ICursorArray that, Action action) { IEnumerator iter = that.GetEnumerator(); foreach (CursorType item in this) { bool ok = iter.MoveNext(); Assert.IsTrue(ok); action(); } }
/// <summary> /// Invoke an element-wise action across three arrays. /// </summary> /// <param name="a">An array of the same size as <c>this</c>. Can be the same object as <c>this</c>.</param> /// <param name="b">An array of the same size as <c>this</c>. Can be the same object as <c>this</c>.</param> /// <param name="action">A delegate which accesses the array cursors.</param> public void ForEach(ICursorArray a, ICursorArray b, Action action) { IEnumerator a_iter = a.GetEnumerator(); IEnumerator b_iter = b.GetEnumerator(); foreach (CursorType item in this) { bool a_ok = a_iter.MoveNext(); bool b_ok = b_iter.MoveNext(); Assert.IsTrue(a_ok); Assert.IsTrue(b_ok); action(); } }