diff options
author | Marek Safar <marek.safar@gmail.com> | 2017-02-22 13:02:09 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-02-22 22:20:36 +0300 |
commit | f03f5bf483165c8661194a7839d9ec04a699c4c2 (patch) | |
tree | 4f8d6b86c4a98f44e00791d37e646d51780056f7 | |
parent | 53925041e12a82ae1a71aba31d1b5f0eb779f411 (diff) |
Bump corefx
m--------- | external/corefx | 0 | ||||
-rw-r--r-- | mcs/class/corlib/System/Array.cs | 28 |
2 files changed, 28 insertions, 0 deletions
diff --git a/external/corefx b/external/corefx -Subproject 10b23d348821eeebbfe1db0b306e2d764655b4e +Subproject c00dde208d25f180d881c37d465410ed2edd693 diff --git a/mcs/class/corlib/System/Array.cs b/mcs/class/corlib/System/Array.cs index 2027b128e93..d2565a3c209 100644 --- a/mcs/class/corlib/System/Array.cs +++ b/mcs/class/corlib/System/Array.cs @@ -1290,6 +1290,34 @@ namespace System } } + public static void Reverse<T>(T[] array) + { + if (array == null) + throw new ArgumentNullException (nameof (array)); + + Reverse (array, 0, array.Length); + } + + public static void Reverse<T>(T[] array, int index, int length) + { + if (array == null) + throw new ArgumentNullException (nameof (array)); + if (index < 0 || length < 0) + throw new ArgumentOutOfRangeException ((index < 0 ? nameof (index) : nameof (length))); + if (array.Length - index < length) + throw new ArgumentException (); + + int i = index; + int j = index + length - 1; + while (i < j) { + T temp = array [i]; + array [i] = array [j]; + array [j] = temp; + i++; + j--; + } + } + [ReliabilityContractAttribute (Consistency.MayCorruptInstance, Cer.MayFail)] public static void Sort (Array array) { |