Client LuaCsForBarotrauma
ReadOnlyListExtensions.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 
5 namespace Barotrauma
6 {
7  public static class ReadOnlyListExtensions
8  {
9  public static int IndexOf<T>(this IReadOnlyList<T> list, T elem)
10  => list.IndexOf(input => input.Equals(elem));
11 
12  public static int IndexOf<T>(this IReadOnlyList<T> list, Func<T, bool> predicate)
13  {
14  for (int i = 0; i < list.Count; i++)
15  {
16  if (predicate(list[i])) { return i; }
17  }
18  return -1;
19  }
20 
21  public static T Find<T>(this IReadOnlyList<T> list, Func<T, bool> predicate)
22  {
23  return list.FirstOrDefault(predicate);
24  }
25  }
26 }