wasSharp – Diff between revs 10 and 11
?pathlinks?
Rev 10 | Rev 11 | |||
---|---|---|---|---|
Line 9... | Line 9... | |||
9 | |
9 | |
|
10 | namespace wasSharp.Collections.Utilities |
10 | namespace wasSharp.Collections.Utilities |
|
11 | { |
11 | { |
|
12 | public static class Extensions |
12 | public static class Extensions |
|
13 | { |
- | ||
14 | /////////////////////////////////////////////////////////////////////////// |
- | ||
15 | // Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 // |
- | ||
16 | /////////////////////////////////////////////////////////////////////////// |
- | ||
17 | /// <summary> |
- | ||
18 | /// Returns true of an enumerable contains more than one element. |
- | ||
19 | /// </summary> |
- | ||
20 | /// <typeparam name="T">the type of the enumeration</typeparam> |
- | ||
21 | /// <param name="e">the enumeration</param> |
- | ||
22 | /// <returns>true if enumeration contains more than one element</returns> |
- | ||
23 | /// <remarks>O(2) worst case</remarks> |
- | ||
24 | public static bool Some<T>(this IEnumerable<T> e) |
- | ||
25 | { |
- | ||
26 | var i = 0; |
- | ||
27 | using (var iter = e.GetEnumerator()) |
- | ||
28 | { |
- | ||
29 | while (iter.MoveNext()) |
- | ||
30 | { |
- | ||
31 | if (++i > 1) |
- | ||
32 | return true; |
- | ||
33 | } |
- | ||
34 | return false; |
- | ||
35 | } |
- | ||
Line 36... | Line 13... | |||
36 | } |
13 | { |
|
37 | |
14 | |
|
38 | /// <summary> |
15 | /// <summary> |
|
39 | /// Compares two dictionaries for equality. |
16 | /// Compares two dictionaries for equality. |