aboutsummaryrefslogtreecommitdiff
path: root/src/Jellyfin.Extensions/CopyToExtensions.cs
diff options
context:
space:
mode:
authorBrian J. Murrell <brian@interlinx.bc.ca>2021-11-29 17:53:26 -0500
committerBrian J. Murrell <brian@interlinx.bc.ca>2021-11-29 17:53:26 -0500
commit757970bfc17b0eb1566b45fbe700dcb16423b190 (patch)
tree63fbc171621f5ec7ae156f341d9b1df37643deac /src/Jellyfin.Extensions/CopyToExtensions.cs
parenta3a4689af22693b535e80b98624831866fda2a61 (diff)
parentc677b4f6b7f7e874097aa2cee866d9ed1e574178 (diff)
Merge remote-tracking branch 'origin/master' into HEAD
Diffstat (limited to 'src/Jellyfin.Extensions/CopyToExtensions.cs')
-rw-r--r--src/Jellyfin.Extensions/CopyToExtensions.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/Jellyfin.Extensions/CopyToExtensions.cs b/src/Jellyfin.Extensions/CopyToExtensions.cs
new file mode 100644
index 0000000000..72d37b5b6a
--- /dev/null
+++ b/src/Jellyfin.Extensions/CopyToExtensions.cs
@@ -0,0 +1,26 @@
+using System.Collections.Generic;
+
+namespace Jellyfin.Extensions
+{
+ /// <summary>
+ /// Provides <c>CopyTo</c> extensions methods for <see cref="IReadOnlyList{T}" />.
+ /// </summary>
+ public static class CopyToExtensions
+ {
+ /// <summary>
+ /// Copies all the elements of the current collection to the specified list
+ /// starting at the specified destination array index. The index is specified as a 32-bit integer.
+ /// </summary>
+ /// <param name="source">The current collection that is the source of the elements.</param>
+ /// <param name="destination">The list that is the destination of the elements copied from the current collection.</param>
+ /// <param name="index">A 32-bit integer that represents the index in <c>destination</c> at which copying begins.</param>
+ /// <typeparam name="T">The type of the array.</typeparam>
+ public static void CopyTo<T>(this IReadOnlyList<T> source, IList<T> destination, int index = 0)
+ {
+ for (int i = 0; i < source.Count; i++)
+ {
+ destination[index + i] = source[i];
+ }
+ }
+ }
+}