summaryrefslogtreecommitdiff
path: root/Extensions.cs
blob: 6303c8c5eb22e2b5cfabc25d68cd7e6d78ec14bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
namespace Q1Emu;

using System.Collections.Generic;

public static class Extensions
{
    public static IEnumerable<int> AllIndexesOf<T>(this IEnumerable<T> arr, T q)
    {
        var indexes = new List<int>();
        int index = 0;

        foreach (var item in arr)
        {
            if (EqualityComparer<T>.Default.Equals(item, q))
            {
                indexes.Add(index);
            }
            index++;
        }

        return indexes;
    }
}