wasSharp – Diff between revs 27 and 29

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 27 Rev 29
Line 35... Line 35...
35 return false; 35 return false;
36 } 36 }
37 } 37 }
Line 38... Line 38...
38   38  
39 /// <summary> 39 /// <summary>
-   40 /// Sequentially removes all the elements from the first sequence that are in the second sequence
40 /// Sequentially removes all the elements from the first sequence that are in the second sequence. 41 /// or all the elements from the second sequence that are in the first sequence.
41 /// </summary> 42 /// </summary>
42 /// <typeparam name="T">the type o the collection</typeparam> 43 /// <typeparam name="T">the type o the collection</typeparam>
43 /// <param name="o">the first sequence to remove from</param> 44 /// <param name="o">the first sequence to remove from</param>
44 /// <param name="p">the second sequence to remove</param> 45 /// <param name="p">the second sequence to remove</param>
45 /// <returns>the first sequence excluding the second sequence</returns> 46 /// <returns>the first sequence excluding the second sequence or the second sequence excluding the first sequence</returns>
46 public static IEnumerable<T> SequenceExcept<T>(this IEnumerable<T> o, IEnumerable<T> p) where T : IEquatable<T> 47 public static IEnumerable<T> SequenceExceptAny<T>(this IEnumerable<T> o, IEnumerable<T> p) where T : IEquatable<T>
47 { 48 {
48 var l = new List<T>(o); 49 var l = new List<T>(o);
49 var r = new List<T>(p); 50 var r = new List<T>(p);
50 return l.Count > r.Count 51 return l.Count > r.Count
Line 53... Line 54...
53 .Where(q => q != null && !q.Equals(default(T))) 54 .Where(q => q != null && !q.Equals(default(T)))
54 : r.Zip(l, (x, y) => x.Equals(y) ? default(T) : y) 55 : r.Zip(l, (x, y) => x.Equals(y) ? default(T) : y)
55 .Concat(r.Skip(l.Count())) 56 .Concat(r.Skip(l.Count()))
56 .Where(q => q != null && !q.Equals(default(T))); 57 .Where(q => q != null && !q.Equals(default(T)));
57 } 58 }
-   59  
-   60 /// <summary>
-   61 /// Sequentially removes all the elements from the first sequence that are in the second sequence.
-   62 /// </summary>
-   63 /// <typeparam name="T">the type o the collection</typeparam>
-   64 /// <param name="o">the first sequence to remove from</param>
-   65 /// <param name="p">the second sequence to remove</param>
-   66 /// <returns>the first sequence excluding the second sequence</returns>
-   67 public static IEnumerable<T> SequenceExcept<T>(this IEnumerable<T> a, IEnumerable<T> b) where T : IEquatable<T>
-   68 {
-   69 var ea = a.GetEnumerator();
-   70 var eb = b.GetEnumerator();
-   71 while (ea.MoveNext())
-   72 {
-   73 if (eb.MoveNext() && ea.Current.Equals(eb.Current))
-   74 continue;
-   75 yield return ea.Current;
-   76 }
-   77 }
58 } 78 }
59 } 79 }