2 using System
.Collections
.Generic
;
4 namespace IEnumerableExtras
6 public static class ListIndexOf
9 /// Return index of first element of this list satisfying filter function or -1.
11 /// <typeparam name="T"></typeparam>
12 /// <param name="list"></param>
13 /// <param name="filterFunc"></param>
14 /// <returns></returns>
15 public static int IndexOf
< T
>( this IList
<T
> list
, Func
<T
, bool> filterFunc
)
17 return IndexOf( list
, filterFunc
, 1 );
21 /// Return index of first element of this list satisfying filter function or -1.
23 /// <typeparam name="T"></typeparam>
24 /// <param name="list"></param>
25 /// <param name="quant">Quntifier, index will be divisible by this number</param>
26 /// <param name="filterFunc"></param>
27 /// <returns></returns>
28 public static int IndexOf
< T
>( this IList
<T
> list
, Func
<T
, bool> filterFunc
, int quant
)
32 throw new ArgumentException( "Qunatifier must be greater than zero.", "quant" );
36 for ( int i
= 0; i
< list
.Count
; i
+= quant
)
38 if ( filterFunc( list
[ i
] ) )