[corlib] generic collections from reference sources
[mono.git] / mcs / class / corlib / System / Array.cs
index 1e8d89caaf061479e3600738cd4e0e1340d75450..ab97679e4f0ffbf3f857656ca2161f936b5803c6 100644 (file)
@@ -933,6 +933,9 @@ namespace System
                        int source_pos = sourceIndex - sourceArray.GetLowerBound (0);
                        int dest_pos = destinationIndex - destinationArray.GetLowerBound (0);
 
+                       if (dest_pos < 0)
+                               throw new ArgumentOutOfRangeException ("destinationIndex", "Index was less than the array's lower bound in the first dimension.");
+
                        // re-ordered to avoid possible integer overflow
                        if (source_pos > sourceArray.Length - length)
                                throw new ArgumentException ("length");
@@ -1004,7 +1007,7 @@ namespace System
 
                [ReliabilityContractAttribute (Consistency.MayCorruptInstance, Cer.MayFail)]
                public static void Copy (Array sourceArray, long sourceIndex, Array destinationArray,
-                                        long destinationIndex, long length)
+                                                                long destinationIndex, long length)
                {
                        if (sourceArray == null)
                                throw new ArgumentNullException ("sourceArray");
@@ -2726,7 +2729,7 @@ namespace System
 
                        public object Current {
                                get {
-                                       // Exception messages based on MS implementation
+                                       // Exception messages based on MS implementation
                                        if (currentpos < 0 )
                                                throw new InvalidOperationException (Locale.GetText (
                                                        "Enumeration has not started."));
@@ -3170,5 +3173,17 @@ namespace System
                }
 
                #endregion
+
+               internal sealed class FunctorComparer<T> : IComparer<T> {
+                       Comparison<T> comparison;
+
+                       public FunctorComparer(Comparison<T> comparison) {
+                               this.comparison = comparison;
+                       }
+
+                       public int Compare(T x, T y) {
+                               return comparison(x, y);
+                       }
+               }
        }
 }