mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
3a445ba3de
* re-added taskbar icon overlays and progress bars * got rid of the token button in ThreadWindow; moved to ThreadList context menu git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1948 21ef857c-d57f-4fe0-8362-d861dc6d29cd
47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace System.Linq
|
|
{
|
|
public static partial class Enumerable
|
|
{
|
|
public static IEnumerable<TSource> Reverse<TSource> (this IEnumerable<TSource> source)
|
|
{
|
|
if (source == null) throw new ArgumentNullException ("source");
|
|
|
|
var list = source.ToList ();
|
|
|
|
for (int i = list.Count - 1; i >= 0; i--)
|
|
yield return list [i];
|
|
}
|
|
|
|
public static IEnumerable<TSource> DefaultIfEmpty<TSource> (this IEnumerable<TSource> source)
|
|
{
|
|
return source.DefaultIfEmpty (default (TSource));
|
|
}
|
|
|
|
public static IEnumerable<TSource> DefaultIfEmpty<TSource> (this IEnumerable<TSource> source, TSource defaultValue)
|
|
{
|
|
if (source == null) throw new ArgumentNullException ("source");
|
|
|
|
bool empty = true;
|
|
foreach (TSource element in source)
|
|
{
|
|
empty = false;
|
|
yield return element;
|
|
}
|
|
if (empty) yield return defaultValue;
|
|
}
|
|
|
|
// A bonus query operator! It allows you to do this:
|
|
// myQuery.ForEach (Console.WriteLine);
|
|
|
|
public static void ForEach<TSource> (this IEnumerable<TSource> source, Action<TSource> action)
|
|
{
|
|
foreach (TSource element in source)
|
|
action (element);
|
|
}
|
|
}
|
|
}
|