[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/killvxk/ClearScript/master/ClearScript/Util/ArrayHelpers.cs [Back]  [Original]

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Linq;

namespace Microsoft.ClearScript.Util
{
    internal static class ArrayHelpers
    {
        public static void Iterate(this Array array, Action action)
        {
            if (array.Rank > 0)
            {
                var dimensions = Enumerable.Range(0, array.Rank);
                if (dimensions.Aggregate(1, (count, dimension) => count * array.GetLength(dimension)) > 0)
                {
                    Iterate(array, new int[array.Rank], 0, action);
                }
            }
        }

        private static void Iterate(Array array, int[] indices, int dimension, Action action)
        {
            if (dimension >= indices.Length)
            {
                action(indices);
            }
            else
            {
                var lowerBound = array.GetLowerBound(dimension);
                var upperBound = array.GetUpperBound(dimension);
                for (var index = lowerBound; index 

Web Proxy Viewer  |  New URL  |  Original Page