aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/IO/SharpCifs/Util/Sharpen/Arrays.cs
blob: b3a0a85fa8e3853c9bf856566da191b94d5d4fc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Linq;

namespace SharpCifs.Util.Sharpen
{
    public class Arrays
	{
		public static List<T> AsList<T> (params T[] array)
		{
			return array.ToList ();
		}

		public static bool Equals<T> (T[] a1, T[] a2)
		{
			if (a1.Length != a2.Length) {
				return false;
			}
		    return !a1.Where((t, i) => !t.Equals(a2[i])).Any();
		}

		public static void Fill<T> (T[] array, T val)
		{
			Fill (array, 0, array.Length, val);
		}

		public static void Fill<T> (T[] array, int start, int end, T val)
		{
			for (int i = start; i < end; i++) {
				array[i] = val;
			}
		}

		public static void Sort (string[] array)
		{
			Array.Sort (array, (s1,s2) => string.CompareOrdinal (s1,s2));
		}

		public static void Sort<T> (T[] array)
		{
			Array.Sort (array);
		}

		public static void Sort<T> (T[] array, IComparer<T> c)
		{
			Array.Sort (array, c);
		}

		public static void Sort<T> (T[] array, int start, int count)
		{
			Array.Sort (array, start, count);
		}

		public static void Sort<T> (T[] array, int start, int count, IComparer<T> c)
		{
			Array.Sort (array, start, count, c);
		}
	}
}