diff --git a/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs index f1d54bab94b7de79cb2ec267238cdb72f86e9017..0768a55c23be352e0ee65621e2dd80a59750e1d6 100644 --- a/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs @@ -39,6 +39,10 @@ namespace TUGraz.VectoCommon.Utils { public static class EnumerableExtensionMethods { + public static IEnumerable<(T value, int index)> Select<T>(this IEnumerable<T> self) => + self.Select((value, index) => (value, index)); + + public static IEnumerable<double> ToDouble(this IEnumerable<string> self, double? defaultValue = null) { return self.Select(s => s.ToDouble(defaultValue)); @@ -94,6 +98,14 @@ namespace TUGraz.VectoCommon.Utils } } + /// <summary> + /// Zips all elements of two enumerable together. If the enumerables dont have the same length an exception is thrown. + /// </summary> + /// <exception cref="System.InvalidOperationException">Enumeration already finished. Thrown if the enumerables dont have the same length.</exception> + public static IEnumerable<(T1 firstEnumerable, T2 secondEnumerable)> Zip<T1,T2>(this IEnumerable<T1> self, IEnumerable<T2> other) => + self.ZipAll(other, (arg1, arg2) => (arg1,arg2)); + + /// <summary> /// Sums up the values of selector. /// </summary>