#nullable disable namespace Terminal.Gui.Views; /// /// Extends with methods to find the index of an element. /// public static class ReadOnlyCollectionExtensions { /// /// Returns the index of the first element in the collection that matches the specified predicate. /// /// /// /// /// public static int IndexOf (this IReadOnlyCollection self, Func predicate) { var i = 0; foreach (T element in self) { if (predicate (element)) { return i; } i++; } return -1; } /// /// Returns the index of the first element in the collection that matches the specified predicate. /// /// /// /// /// public static int IndexOf (this IReadOnlyCollection self, T toFind) { var i = 0; foreach (T element in self) { if (Equals (element, toFind)) { return i; } i++; } return -1; } }