public static void ForEach(this Array array, Action<Array, int[]> action) { if (array.LongLength == 0) return; ArrayTraverse walker = new ArrayTraverse(array); do action(array, walker.Position); while (walker.Step()); }
private static void ForEach(this Array array, Action <Array, int[]> action) { if (array.LongLength == 0) { return; } ArrayTraverse walker = new ArrayTraverse(array); do { action?.Invoke(array, walker._position); }while (walker.Step()); }
public static void ForEach(this Array array, Action <Array, int[]> action) { if (array.LongLength == 0) { return; } ArrayTraverse traverse = new ArrayTraverse(array); do { action(array, traverse.Position); } while (traverse.Step()); }
public static void ForEach(this Array array, Action <Array, int[]> action) { Contract.Requires(array != null); if (array.LongLength == 0) { return; } ArrayTraverse walker = new ArrayTraverse(array); do { action(array, walker.Position); }while (walker.Step()); }
/// <summary> /// Traverse through the array and raise a callback action /// </summary> /// <param name="array">The array that is to be traversed</param> /// <param name="action">The action that is to be raised for all of the elements in the array</param> private static void ForEach(this Array array, Action <Array, int[]> action) { // If the array is empty, don't bother if (array.LongLength == 0) { return; } // Traverse the array to raise the callback action ArrayTraverse walker = new ArrayTraverse(array); do { action(array, walker.Position); }while (walker.Step()); }
public static IEnumerable <int[]> Indices(this Array array) { if (array == null) { yield break; } if (array.Length == 0) { yield break; } var rank = array.Rank; var walker = new ArrayTraverse(array); do { var result = new int[rank]; walker.CurrentPosition.CopyTo(result, 0); // Merge forces a copy, so the there is a reference break; yield return(result); } while (walker.Step()); }