summaryrefslogtreecommitdiff
path: root/Emulator/Extensions.cs
blob: 3cc980d0779476c938e8f9caa5407ca3826339c7 (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 Q1.Emulator;

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;
    }
}