| | 1 | | using VRC.Core; |
| | 2 | |
|
| | 3 | | namespace Kemocade.Vrc.Data.Extensions |
| | 4 | | { |
| | 5 | | public static partial class DataDictionaryExtensions |
| | 6 | | { |
| | 7 | | const char DOT = '.'; |
| | 8 | | private static T[] Fit<T>(T[] source, int count) |
| 16 | 9 | | { |
| | 10 | | // No need to make a copy |
| 24 | 11 | | if (source.Length == count) { return source; } |
| | 12 | |
|
| | 13 | | // Shrink the array if needed |
| 12 | 14 | | T[] copy = new T[count]; |
| 12 | 15 | | System.Array.Copy(source, copy, count); |
| 12 | 16 | | return copy; |
| 16 | 17 | | } |
| | 18 | |
|
| | 19 | | private static bool Contains<T>(T[] source, T target) |
| 46 | 20 | | { |
| 263 | 21 | | foreach (T t in source) |
| 74 | 22 | | { |
| 120 | 23 | | if (t.Equals(target)) { return true; } |
| 51 | 24 | | } |
| 23 | 25 | | return false; |
| 46 | 26 | | } |
| | 27 | |
|
| | 28 | | private static bool ContainsNone<T>(T[] source, T[] targets) |
| 29 | 29 | | { |
| 144 | 30 | | foreach (T target in targets) |
| 38 | 31 | | { |
| 76 | 32 | | if (Contains(source, target)) { return false; } |
| 19 | 33 | | } |
| 10 | 34 | | return true; |
| 29 | 35 | | } |
| | 36 | |
|
| | 37 | | private static bool ContainsAll<T>(T[] source, T[] targets) |
| 5 | 38 | | { |
| 27 | 39 | | foreach (T target in targets) |
| 8 | 40 | | { |
| 16 | 41 | | if (!Contains(source, target)) { return false; } |
| 4 | 42 | | } |
| 1 | 43 | | return true; |
| 5 | 44 | | } |
| | 45 | |
|
| | 46 | | private static bool ContainsAny<T>(T[] source, T[] targets) => |
| 19 | 47 | | !ContainsNone(source, targets); |
| | 48 | | } |
| | 49 | | } |