summaryrefslogtreecommitdiff
path: root/src/Notepad/Infrastructure/Extensions/EnumerableExtensions.cs
blob: d57c0e1497cca74a919df9b1bbbbf77c8d7fc8d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;

namespace Notepad.Infrastructure.Extensions {
    public static class EnumerableExtensions {
        public static void Walk<T>(this IEnumerable<T> itemsToWalk) {
            foreach (var item in itemsToWalk) {}
        }

        public static IEnumerable<T> ThatSatisfy<T>(this IEnumerable<T> itemsToPeekInto, Predicate<T> criteriaToSatisfy) {
            foreach (var item in itemsToPeekInto) {
                if (item.Satisfies(criteriaToSatisfy)) {
                    yield return item;
                }
            }
        }

        public static IEnumerable<T> SortedUsing<T>(this IEnumerable<T> itemsToSort, IComparer<T> sortingAlgorithm) {
            var sortedItems = new List<T>(itemsToSort);
            sortedItems.Sort(sortingAlgorithm);
            return sortedItems;
        }
    }
}