wasSharp

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 28  →  ?path2? @ 29
/Linq.cs
@@ -37,13 +37,14 @@
}
 
/// <summary>
/// Sequentially removes all the elements from the first sequence that are in the second sequence.
/// Sequentially removes all the elements from the first sequence that are in the second sequence
/// or all the elements from the second sequence that are in the first sequence.
/// </summary>
/// <typeparam name="T">the type o the collection</typeparam>
/// <param name="o">the first sequence to remove from</param>
/// <param name="p">the second sequence to remove</param>
/// <returns>the first sequence excluding the second sequence</returns>
public static IEnumerable<T> SequenceExcept<T>(this IEnumerable<T> o, IEnumerable<T> p) where T : IEquatable<T>
/// <returns>the first sequence excluding the second sequence or the second sequence excluding the first sequence</returns>
public static IEnumerable<T> SequenceExceptAny<T>(this IEnumerable<T> o, IEnumerable<T> p) where T : IEquatable<T>
{
var l = new List<T>(o);
var r = new List<T>(p);
@@ -55,5 +56,24 @@
.Concat(r.Skip(l.Count()))
.Where(q => q != null && !q.Equals(default(T)));
}
 
/// <summary>
/// Sequentially removes all the elements from the first sequence that are in the second sequence.
/// </summary>
/// <typeparam name="T">the type o the collection</typeparam>
/// <param name="o">the first sequence to remove from</param>
/// <param name="p">the second sequence to remove</param>
/// <returns>the first sequence excluding the second sequence</returns>
public static IEnumerable<T> SequenceExcept<T>(this IEnumerable<T> a, IEnumerable<T> b) where T : IEquatable<T>
{
var ea = a.GetEnumerator();
var eb = b.GetEnumerator();
while (ea.MoveNext())
{
if (eb.MoveNext() && ea.Current.Equals(eb.Current))
continue;
yield return ea.Current;
}
}
}
}