Esempio n. 1
0
    /// <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 <Index4D, 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 <Index4D, T>(index, array[index.X, index.Y, index.Z, index.W]));
        }
    }
Esempio n. 2
0
    /// <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 <Index4D> GetIndices <T>(this T[,,,] array)
    {
        Contracts.Requires.That(array != null);

        foreach (var index in Index.Range(array.GetLowerBounds(), array.GetDimensions()))
        {
            yield return(index);
        }
    }