summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS/Extensions/ArrayExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Extensions/ArrayExtensions.cs')
-rw-r--r--Xamarin.Forms.Platform.iOS/Extensions/ArrayExtensions.cs38
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