diff options
author | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 13:02:25 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 16:13:41 -0700 |
commit | 17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch) | |
tree | b5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Platform.iOS/Extensions/ArrayExtensions.cs | |
download | xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2 xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip |
Initial import
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Extensions/ArrayExtensions.cs')
-rw-r--r-- | Xamarin.Forms.Platform.iOS/Extensions/ArrayExtensions.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Extensions/ArrayExtensions.cs b/Xamarin.Forms.Platform.iOS/Extensions/ArrayExtensions.cs new file mode 100644 index 00000000..9adafecb --- /dev/null +++ b/Xamarin.Forms.Platform.iOS/Extensions/ArrayExtensions.cs @@ -0,0 +1,38 @@ +using System; + +namespace Xamarin.Forms.Platform.iOS +{ + internal static class ArrayExtensions + { + public static T[] Insert<T>(this T[] self, int index, T item) + { + var result = new T[self.Length + 1]; + if (index > 0) + Array.Copy(self, result, index); + + result[index] = item; + + if (index < self.Length) + Array.Copy(self, index, result, index + 1, result.Length - index - 1); + + return result; + } + + public static T[] Remove<T>(this T[] self, T item) + { + return self.RemoveAt(self.IndexOf(item)); + } + + public static T[] RemoveAt<T>(this T[] self, int index) + { + var result = new T[self.Length - 1]; + if (index > 0) + Array.Copy(self, result, index); + + if (index < self.Length - 1) + Array.Copy(self, index + 1, result, index, self.Length - index - 1); + + return result; + } + } +}
\ No newline at end of file |