Files
OpenRA/OpenRa.Game/Exts.cs

32 lines
715 B
C#

using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
namespace OpenRa.Game
{
static class Exts
{
public static string F(this string fmt, params object[] args)
{
return string.Format(fmt, args);
}
public static bool HasModifier(this Modifiers k, Modifiers mod)
{
return (k & mod) == mod;
}
public static IEnumerable<T> SymmetricDifference<T>(this IEnumerable<T> xs, IEnumerable<T> ys)
{
// this is probably a shockingly-slow way to do this, but it's concise.
return xs.Except(ys).Concat(ys.Except(xs));
}
public static float Product(this IEnumerable<float> xs)
{
return xs.Aggregate((a, x) => a * x);
}
}
}