public static void ForEach <TSource>(this ReadOnlySpan <TSource> source, ActionAt <TSource> action)
 {
     for (var index = 0; index < source.Length; index++)
     {
         action(source[index], index);
     }
 }
        static void ForEach <TList, TSource, TResult>(this TList source, ActionAt <TResult> action, Predicate <TSource> predicate, Selector <TSource, TResult> selector, int skipCount, int takeCount)
            where TList : notnull, IReadOnlyList <TSource>
        {
            var itemIndex = 0;

            if (skipCount == 0)
            {
                for (var index = 0; index < takeCount; index++)
                {
                    var item = source[index];
                    if (predicate(item))
                    {
                        action(selector(item), itemIndex++);
                    }
                }
            }
            else
            {
                for (var index = 0; index < takeCount; index++)
                {
                    var item = source[index + skipCount];
                    if (predicate(item))
                    {
                        action(selector(item), itemIndex++);
                    }
                }
            }
        }
 static void ForEach <TSource, TResult>(this ReadOnlySpan <TSource> source, ActionAt <TResult> action, SelectorAt <TSource, TResult> selector)
 {
     for (var index = 0; index < source.Length; index++)
     {
         action(selector(source[index], index), index);
     }
 }
        public static void ForEach <TList, TSource>(this TList source, ActionAt <TSource> action)
            where TList : notnull, IReadOnlyList <TSource>
        {
            if (action is null)
            {
                Throw.ArgumentNullException(nameof(action));
            }

            ForEach <TList, TSource>(source, action, 0, source.Count);
        }
        static void ForEach <TSource, TResult>(this ReadOnlySpan <TSource> source, ActionAt <TResult> action, Predicate <TSource> predicate, Selector <TSource, TResult> selector)
        {
            var itemIndex = 0;

            for (var index = 0; index < source.Length; index++)
            {
                var item = source[index];
                if (predicate(item))
                {
                    action(selector(item), itemIndex++);
                }
            }
        }
        static void ForEach <TSource>(this ReadOnlySpan <TSource> source, ActionAt <TSource> action, PredicateAt <TSource> predicate)
        {
            var itemIndex = 0;

            for (var index = 0; index < source.Length; index++)
            {
                var item = source[index];
                if (predicate(item, index))
                {
                    action(item, itemIndex++);
                }
            }
        }
 static void ForEach <TList, TSource, TResult>(this TList source, ActionAt <TResult> action, SelectorAt <TSource, TResult> selector, int skipCount, int takeCount)
     where TList : notnull, IReadOnlyList <TSource>
 {
     if (skipCount == 0)
     {
         for (var index = 0; index < takeCount; index++)
         {
             action(selector(source[index], index), index);
         }
     }
     else
     {
         for (var index = 0; index < takeCount; index++)
         {
             action(selector(source[index + skipCount], index), index);
         }
     }
 }
 public static void ForEach <TKey, TValue>(this SortedDictionary <TKey, TValue> source, ActionAt <KeyValuePair <TKey, TValue> > action)
 => ValueReadOnlyCollection.ForEach <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue> >(new ValueWrapper <TKey, TValue>(source), action);
        public static void ForEach <TEnumerable, TEnumerator, TSource>(this TEnumerable source, ActionAt <TSource> action)
            where TEnumerable : notnull, IValueEnumerable <TSource, TEnumerator>
            where TEnumerator : struct, IEnumerator <TSource>
        {
            if (action is null)
            {
                Throw.ArgumentNullException(nameof(action));
            }

            using var enumerator = source.GetEnumerator();
            checked
            {
                for (var index = 0; enumerator.MoveNext(); index++)
                {
                    action(enumerator.Current, index);
                }
            }
        }
 static void ForEach <TEnumerable, TEnumerator, TSource, TResult>(this TEnumerable source, ActionAt <TResult> action, Predicate <TSource> predicate, Selector <TSource, TResult> selector)
     where TEnumerable : notnull, IValueEnumerable <TSource, TEnumerator>
     where TEnumerator : struct, IEnumerator <TSource>
 {
     using var enumerator = source.GetEnumerator();
     checked
     {
         var itemIndex = 0;
         for (var index = 0; enumerator.MoveNext(); index++)
         {
             var item = enumerator.Current;
             if (predicate(item))
             {
                 action(selector(item), itemIndex++);
             }
         }
     }
 }
Пример #11
0
 public static void ForEach <TKey, TValue>(this Dictionary <TKey, TValue> .KeyCollection source, ActionAt <TKey> action)
 => ValueReadOnlyCollection.ForEach <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .KeyCollection.Enumerator, TKey>(new ValueWrapper <TKey, TValue>(source), action);
Пример #12
0
 public static void ForEach <TSource>(this Span <TSource> source, ActionAt <TSource> action)
 => ForEach((ReadOnlySpan <TSource>)source, action);
 public static void ForEach <TSource>(this List <TSource> source, ActionAt <TSource> action)
 => ReadOnlyList.ForEach <List <TSource>, TSource>(source, action);
 public static void ForEach <TSource>(this ImmutableArray <TSource> source, ActionAt <TSource> action)
 => ReadOnlyList.ForEach <ImmutableArray <TSource>, TSource>(source, action);
 public static void ForEach <TSource>(this ReadOnlyMemory <TSource> source, ActionAt <TSource> action)
 => ForEach(source.Span, action);
Пример #16
0
 public static void ForEach <TSource>(this SortedSet <TSource> source, ActionAt <TSource> action)
 => ValueReadOnlyCollection.ForEach <ValueWrapper <TSource>, SortedSet <TSource> .Enumerator, TSource>(new ValueWrapper <TSource>(source), action);
Пример #17
0
 public static void ForEach <TSource>(this ImmutableQueue <TSource> source, ActionAt <TSource> action)
 => ValueEnumerable.ForEach <ValueWrapper <TSource>, ValueWrapper <TSource> .Enumerator, TSource>(new ValueWrapper <TSource>(source), action);
 static void ForEach <TEnumerable, TEnumerator, TSource, TResult>(this TEnumerable source, ActionAt <TResult> action, SelectorAt <TSource, TResult> selector)
     where TEnumerable : notnull, IValueEnumerable <TSource, TEnumerator>
     where TEnumerator : struct, IEnumerator <TSource>
 {
     using var enumerator = source.GetEnumerator();
     checked
     {
         for (var index = 0; enumerator.MoveNext(); index++)
         {
             action(selector(enumerator.Current, index), index);
         }
     }
 }