Spring – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using System.Collections.Generic; |
2 | |||
3 | namespace Spring.Utilities |
||
4 | { |
||
5 | public static class Extensions |
||
6 | { |
||
7 | #region Public Methods |
||
8 | |||
9 | /// <summary> |
||
10 | /// Determines if the sequence a is contained within b. |
||
11 | /// </summary> |
||
12 | /// <typeparam name="T">an equatable type</typeparam> |
||
13 | /// <param name="a">the first sequence</param> |
||
14 | /// <param name="b">the second sequence</param> |
||
15 | /// <returns>true if the first sequence is contained within the second sequence</returns> |
||
16 | public static bool SequenceContains(this IEnumerable<dynamic> a, IEnumerable<dynamic> b) |
||
17 | { |
||
18 | using (var ea = a.GetEnumerator()) |
||
19 | { |
||
20 | using (var eb = b.GetEnumerator()) |
||
21 | { |
||
22 | var aea = ea.MoveNext(); |
||
23 | var aeb = eb.MoveNext(); |
||
24 | |||
25 | while (aea && aeb) |
||
26 | { |
||
27 | var eac = ea.Current; |
||
28 | var ebc = eb.Current; |
||
29 | |||
30 | if (eac.Equals(ebc)) |
||
31 | { |
||
32 | aea = ea.MoveNext(); |
||
33 | aeb = eb.MoveNext(); |
||
34 | |||
35 | continue; |
||
36 | } |
||
37 | |||
38 | aeb = eb.MoveNext(); |
||
39 | } |
||
40 | |||
41 | return !aea; |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | |||
46 | #endregion |
||
47 | } |
||
48 | } |