public static int[] FindAllIndex<R>(R[] T, Predicate<R> value)
{
int[] values = new int[T.Count<R>(new Func<R,bool>(value))];
int startIndex = 0;
for (int i = 0; i != values.Length; i++)
{
values[i] = Array.FindIndex(T, startIndex, value);
startIndex = values[i] + 1;
}
return values;
}
////Beispiel////
static void Main(string[] args)
{
int[] eins = new int[12] { 3, 3, 2, 2, 3, 3, 3, 2, 1, 2, 3, 1 };
int[] dreien;
dreien = ArrayFunctions.FindAllIndex<int>(eins, (x => x == 3));
foreach (int el in dreien)
{ Console.WriteLine(el); }
Console.ReadLine();
}
//Output 0 , 1 , 4, 5 , 6 , 10