Last change
on this file since 13072 was
13072,
checked in by gkronber, 8 years ago
|
#2499: added code from HeuristicLab.BioBoost.Views (from private repository) nothing much has been changed
|
File size:
529 bytes
|
Rev | Line | |
---|
[13072] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 |
|
---|
| 4 | namespace HeuristicLab.BioBoost.Views {
|
---|
| 5 | public static class EnumerableExtentions {
|
---|
| 6 | /// <summary>
|
---|
| 7 | /// Returns the index of the first element in source matched by predicate.
|
---|
| 8 | /// </summary>
|
---|
| 9 | public static int IndexOfFirst<T>(this IEnumerable<T> source, Func<T, bool> predicate) {
|
---|
| 10 | int i = 0;
|
---|
| 11 | foreach (T item in source) {
|
---|
| 12 | if (predicate(item)) {
|
---|
| 13 | return i;
|
---|
| 14 | }
|
---|
| 15 | i++;
|
---|
| 16 | }
|
---|
| 17 | return -1;
|
---|
| 18 | }
|
---|
| 19 | }
|
---|
| 20 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.