using System;
using System.Runtime.InteropServices;
namespace SharpGen.Runtime
{
public static partial class BooleanHelpers
{
///
/// Converts array to an array of integers.
///
/// The array.
/// The destination array of integers.
public static void ConvertToIntArray(Span array, Span dest)
{
var arrayLength = array.Length;
for (var i = 0; i < arrayLength; i++)
dest[i] = (byte) (array[i] ? 1 : 0);
}
///
/// Converts array to an array of integers.
///
/// The array.
/// The destination array of integers.
public static void ConvertToIntArray(Span array, Span dest)
{
var arrayLength = array.Length;
for (var i = 0; i < arrayLength; i++)
dest[i] = (short) (array[i] ? 1 : 0);
}
///
/// Converts array to an array of integers.
///
/// The array.
/// The destination array of integers.
public static void ConvertToIntArray(Span array, Span dest) =>
MemoryMarshal.Cast(array).CopyTo(dest);
///
/// Converts array to an array of integers.
///
/// The array.
/// The destination array of integers.
public static void ConvertToIntArray(Span array, Span dest)
{
var arrayLength = array.Length;
for (var i = 0; i < arrayLength; i++)
dest[i] = array[i] ? 1 : 0;
}
///
/// Converts array to an array of integers.
///
/// The array.
/// The destination array of integers.
public static void ConvertToIntArray(Span array, Span dest)
{
var arrayLength = array.Length;
for (var i = 0; i < arrayLength; i++)
dest[i] = (sbyte) (array[i] ? 1 : 0);
}
///
/// Converts array to an array of integers.
///
/// The array.
/// The destination array of integers.
public static void ConvertToIntArray(Span array, Span dest)
{
var arrayLength = array.Length;
for (var i = 0; i < arrayLength; i++)
dest[i] = (ushort) (array[i] ? 1 : 0);
}
///
/// Converts array to an array of integers.
///
/// The array.
/// The destination array of integers.
public static void ConvertToIntArray(Span array, Span dest) =>
MemoryMarshal.Cast(array).CopyTo(dest);
///
/// Converts array to an array of integers.
///
/// The array.
/// The destination array of integers.
public static void ConvertToIntArray(Span array, Span dest)
{
var arrayLength = array.Length;
for (var i = 0; i < arrayLength; i++)
dest[i] = (ulong) (array[i] ? 1 : 0);
}
}
}