using System.Collections.Generic; namespace UnityEngine.InputSystem.Utilities { internal static class MiscHelpers { public static TValue GetValueOrDefault(this Dictionary dictionary, TKey key) { return dictionary.TryGetValue(key, out var value) ? value : default; } public static IEnumerable EveryNth(this IEnumerable enumerable, int n, int start = 0) { var index = 0; foreach (var element in enumerable) { if (index < start) { ++index; continue; } if ((index - start) % n == 0) yield return element; ++index; } } public static int IndexOf(this IEnumerable enumerable, TValue value) { var index = 0; foreach (var element in enumerable) if (EqualityComparer.Default.Equals(element, value)) return index; else ++index; return -1; } } }