From f23600caf544268407fa400be05173dfee96aded Mon Sep 17 00:00:00 2001 From: triton Date: Tue, 14 May 2013 18:37:14 +0100 Subject: [PATCH] Added helper Linq method to return an enumeration without its last element. --- src/Generator/Utils/Utils.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Generator/Utils/Utils.cs b/src/Generator/Utils/Utils.cs index e2e5b9bd..87c55e6d 100644 --- a/src/Generator/Utils/Utils.cs +++ b/src/Generator/Utils/Utils.cs @@ -207,6 +207,24 @@ namespace CppSharp } } + public static class LinqHelpers + { + public static IEnumerable WithoutLast(this IEnumerable xs) + { + T lastX = default(T); + + var first = true; + foreach (var x in xs) + { + if (first) + first = false; + else + yield return lastX; + lastX = x; + } + } + } + public static class AssemblyHelpers { public static IEnumerable FindDerivedTypes(this Assembly assembly,