/// <summary> /// Gets an enumerable sequence of all the indices along with their associated values of an array. /// </summary> /// <typeparam name="T">The type of values stored in the array.</typeparam> /// <param name="array">The array.</param> /// <returns>The enumerable sequence of indices paired with their values.</returns> public static IEnumerable <KeyValuePair <Index3D, T> > GetIndexValuePairs <T>(this T[,,] array) { Contracts.Requires.That(array != null); foreach (var index in Index.Range(array.GetLowerBounds(), array.GetDimensions())) { yield return(new KeyValuePair <Index3D, T>(index, array[index.X, index.Y, index.Z])); } }
/// <summary> /// Gets an enumerable sequence of all the indices of an array. /// </summary> /// <typeparam name="T">The type of values stored in the array.</typeparam> /// <param name="array">The array.</param> /// <returns>The enumerable sequence of indices.</returns> public static IEnumerable <Index3D> GetIndices <T>(this T[,,] array) { Contracts.Requires.That(array != null); foreach (var index in Index.Range(array.GetLowerBounds(), array.GetDimensions())) { yield return(index); } }