diff options
Diffstat (limited to 'cs/src/Ice/Arrays.cs')
-rw-r--r-- | cs/src/Ice/Arrays.cs | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/cs/src/Ice/Arrays.cs b/cs/src/Ice/Arrays.cs index b7d2b3b4756..ecba0e893aa 100644 --- a/cs/src/Ice/Arrays.cs +++ b/cs/src/Ice/Arrays.cs @@ -14,85 +14,85 @@ namespace IceUtil public sealed class Arrays { - public static bool Equals(object[] arr1, object[] arr2) + public static bool Equals(object[] arr1, object[] arr2) { - if(object.ReferenceEquals(arr1, arr2)) - { - return true; - } + if(object.ReferenceEquals(arr1, arr2)) + { + return true; + } - if(arr1.Length == arr2.Length) - { - for(int i = 0; i < arr1.Length; i++) - { - if(!arr1[i].Equals(arr2[i])) - { - return false; - } - } + if(arr1.Length == arr2.Length) + { + for(int i = 0; i < arr1.Length; i++) + { + if(!arr1[i].Equals(arr2[i])) + { + return false; + } + } - return true; - } + return true; + } - return false; - } + return false; + } - public static void Sort(ref ArrayList array, IComparer comparator) + public static void Sort(ref ArrayList array, IComparer comparator) { - // - // This Sort method implements the merge sort algorithm - // which is a stable sort (unlike the Sort method of the - // System.Collections.ArrayList which is unstable). - // - Sort1(ref array, 0, array.Count, comparator); - } + // + // This Sort method implements the merge sort algorithm + // which is a stable sort (unlike the Sort method of the + // System.Collections.ArrayList which is unstable). + // + Sort1(ref array, 0, array.Count, comparator); + } - private static void Sort1(ref ArrayList array, int begin, int end, IComparer comparator) + private static void Sort1(ref ArrayList array, int begin, int end, IComparer comparator) { - int mid; - if(end - begin <= 1) - { - return; - } + int mid; + if(end - begin <= 1) + { + return; + } - mid = (begin + end) / 2; - Sort1(ref array, begin, mid, comparator); - Sort1(ref array, mid, end, comparator); - Merge(ref array, begin, mid, end, comparator); - } + mid = (begin + end) / 2; + Sort1(ref array, begin, mid, comparator); + Sort1(ref array, mid, end, comparator); + Merge(ref array, begin, mid, end, comparator); + } - private static void Merge(ref ArrayList array, int begin, int mid, int end, IComparer comparator) + private static void Merge(ref ArrayList array, int begin, int mid, int end, IComparer comparator) { - int i = begin; - int j = mid; - int k = 0; + int i = begin; + int j = mid; + int k = 0; - object[] tmp = new object[end - begin]; - while(i < mid && j < end) - { - if(comparator.Compare(array[i], array[j]) <= 0) - { - tmp[k++] = array[i++]; - } - else - { - tmp[k++] = array[j++]; - } - } + object[] tmp = new object[end - begin]; + while(i < mid && j < end) + { + if(comparator.Compare(array[i], array[j]) <= 0) + { + tmp[k++] = array[i++]; + } + else + { + tmp[k++] = array[j++]; + } + } - while(i < mid) - { - tmp[k++] = array[i++]; - } - while(j < end) - { - tmp[k++] = array[j++]; - } - for(i = 0; i < (end - begin); ++i) - { - array[begin + i] = tmp[i]; - } - } + while(i < mid) + { + tmp[k++] = array[i++]; + } + while(j < end) + { + tmp[k++] = array[j++]; + } + for(i = 0; i < (end - begin); ++i) + { + array[begin + i] = tmp[i]; + } + } } } |