// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Linq; namespace SixLabors.ImageSharp.Tests { public static class ArrayHelper { /// /// Concatenates multiple arrays of the same type into one. /// /// The array type /// The arrays to concatenate. The order is kept /// The concatenated array public static T[] Concat(params T[][] arrs) { var result = new T[arrs.Sum(t => t.Length)]; int offset = 0; for (int i = 0; i < arrs.Length; i++) { arrs[i].CopyTo(result, offset); offset += arrs[i].Length; } return result; } /// /// Creates an array filled with the given value. /// /// The array type /// The value to fill the array with /// The wanted length of the array /// The created array filled with the given value public static T[] Fill(T value, int length) { var result = new T[length]; for (int i = 0; i < length; i++) { result[i] = value; } return result; } /// /// Creates a string from a character with a given length. /// /// The character to fill the string with /// The wanted length of the string /// The filled string public static string Fill(char value, int length) { return "".PadRight(length, value); } } }