Ejemplo n.º 1
0
 /// <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(ShortProcedure procedure)
 {
     for (int i = 0; i < _size;)
     {
         if (!procedure(Get(i++)))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
        /// <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(ShortProcedure procedure)
        {
            // overridden for performance only.
            var theElements = _elements;
            int theSize     = Size;

            for (int i = 0; i < theSize;)
            {
                if (!procedure(theElements[i++]))
                {
                    return(false);
                }
            }
            return(true);
        }