GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat(infra): create `IEnumerable` extension method for iterating with index included
Lars Berger75766bc97fea
diff --git a/GlazeWM.Infrastructure/Utils/EnumerableExtensions.cs b/GlazeWM.Infrastructure/Utils/EnumerableExtensions.csnew file mode 100644index 00000000..cfdae1d4--- /dev/null+++ b/GlazeWM.Infrastructure/Utils/EnumerableExtensions.cs@@ -0,0 +1,16 @@+using System.Collections.Generic;+using System.Linq;++namespace GlazeWM.Infrastructure.Utils+{+ public static class EnumerableExtensions+ {+ /// <summary>+ /// Create an enumerable of tuples with index and item at index. Can be used with foreach loops.+ /// </summary>+ public static IEnumerable<(T item, int index)> WithIndex<T>(this IEnumerable<T> source)+ {+ return source?.Select((item, index) => (item, index)) ?? new List<(T, int)>();+ }+ }+}