// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
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[][] arrays)
{
T[] result = new T[arrays.Sum(t => t.Length)];
int offset = 0;
for (int i = 0; i < arrays.Length; i++)
{
arrays[i].CopyTo(result, offset);
offset += arrays[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)
{
T[] 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 string.Empty.PadRight(length, value);
}
}