~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to contrib/Sharpen/Sharpen/Arrays.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
namespace Sharpen
 
2
{
 
3
        using System;
 
4
        using System.Collections.Generic;
 
5
        using System.Linq;
 
6
 
 
7
        internal class Arrays
 
8
        {
 
9
                public static List<T> AsList<T> (params T[] array)
 
10
                {
 
11
                        return array.ToList<T> ();
 
12
                }
 
13
 
 
14
                public static bool Equals<T> (T[] a1, T[] a2)
 
15
                {
 
16
                        if (a1.Length != a2.Length) {
 
17
                                return false;
 
18
                        }
 
19
                        for (int i = 0; i < a1.Length; i++) {
 
20
                                if (!a1[i].Equals (a2[i])) {
 
21
                                        return false;
 
22
                                }
 
23
                        }
 
24
                        return true;
 
25
                }
 
26
 
 
27
                public static void Fill<T> (T[] array, T val)
 
28
                {
 
29
                        Fill<T> (array, 0, array.Length, val);
 
30
                }
 
31
 
 
32
                public static void Fill<T> (T[] array, int start, int end, T val)
 
33
                {
 
34
                        for (int i = start; i < end; i++) {
 
35
                                array[i] = val;
 
36
                        }
 
37
                }
 
38
 
 
39
                public static void Sort (string[] array)
 
40
                {
 
41
                        Array.Sort (array, (s1,s2) => string.CompareOrdinal (s1,s2));
 
42
                }
 
43
 
 
44
                public static void Sort<T> (T[] array)
 
45
                {
 
46
                        Array.Sort<T> (array);
 
47
                }
 
48
 
 
49
                public static void Sort<T> (T[] array, IComparer<T> c)
 
50
                {
 
51
                        Array.Sort<T> (array, c);
 
52
                }
 
53
 
 
54
                public static void Sort<T> (T[] array, int start, int count)
 
55
                {
 
56
                        Array.Sort<T> (array, start, count);
 
57
                }
 
58
 
 
59
                public static void Sort<T> (T[] array, int start, int count, IComparer<T> c)
 
60
                {
 
61
                        Array.Sort<T> (array, start, count, c);
 
62
                }
 
63
        }
 
64
}