Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.BioBoost/HeuristicLab.Problems.BioBoost.Views/3.3/EnumerableExtentions.cs @ 13072

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
RevLine 
[13072]1using System;
2using System.Collections.Generic;
3
4namespace 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.