/// <summary> /// Applies a procedure to each element of the receiver, if any. /// Starts at index 0, moving rightwards. /// <summary> /// <param name="procedure"> the procedure to be appliedd Stops iteration if the procedure returns <i>false</i>, otherwise continuesd</param> /// <returns><i>false</i> if the procedure stopped before all elements where iterated over, <i>true</i> otherwised</returns> public virtual Boolean ForEach(BooleanProcedure procedure) { for (int i = 0; i < _size;) { if (!procedure(this[i++])) { return(false); } } return(true); }
/// <summary> /// Applies a procedure to each element of the receiver, if any. /// Starts at index 0, moving rightwards. /// <summary> /// <param name="procedure"> the procedure to be appliedd Stops iteration if the procedure returns <i>false</i>, otherwise continuesd</param> /// <returns><i>false</i> if the procedure stopped before all _elements where iterated over, <i>true</i> otherwised</returns> public override Boolean ForEach(BooleanProcedure procedure) { // overridden for performance only. Boolean[] the_elements = _elements; int theSize = Size; for (int i = 0; i < theSize;) { if (!procedure(the_elements[i++])) { return(false); } } return(true); }