using System; using System.Runtime.CompilerServices; namespace SharpGen.Runtime { public static unsafe partial class BooleanHelpers { /// /// Converts bool array to an array of integers. /// /// The bool array. /// The destination array of integers. public static void ConvertToIntArray(Span array, byte* dest) { fixed (void* src = array) Unsafe.CopyBlockUnaligned(dest, src, (uint) array.Length); } /// /// Converts bool array to an array of integers. /// /// The bool array. /// The destination array of integers. public static void ConvertToIntArray(Span array, short* dest) { var arrayLength = array.Length; for (var i = 0; i < arrayLength; i++) dest[i] = (short) (array[i] ? 1 : 0); } /// /// Converts bool array to an array of integers. /// /// The bool array. /// The destination array of integers. public static void ConvertToIntArray(Span array, int* dest) { var arrayLength = array.Length; for (var i = 0; i < arrayLength; i++) dest[i] = array[i] ? 1 : 0; } /// /// Converts bool array to an array of integers. /// /// The bool array. /// The destination array of integers. public static void ConvertToIntArray(Span array, long* dest) { var arrayLength = array.Length; for (var i = 0; i < arrayLength; i++) dest[i] = array[i] ? 1 : 0; } /// /// Converts bool array to an array of integers. /// /// The bool array. /// The destination array of integers. public static void ConvertToIntArray(Span array, sbyte* dest) { fixed (void* src = array) Unsafe.CopyBlockUnaligned(dest, src, (uint) array.Length); } /// /// Converts bool array to an array of integers. /// /// The bool array. /// The destination array of integers. public static void ConvertToIntArray(Span array, ushort* dest) { var arrayLength = array.Length; for (var i = 0; i < arrayLength; i++) dest[i] = (ushort) (array[i] ? 1 : 0); } /// /// Converts bool array to an array of integers. /// /// The bool array. /// The destination array of integers. public static void ConvertToIntArray(Span array, uint* dest) { var arrayLength = array.Length; for (var i = 0; i < arrayLength; i++) dest[i] = (uint) (array[i] ? 1 : 0); } /// /// Converts bool array to an array of integers. /// /// The bool array. /// The destination array of integers. public static void ConvertToIntArray(Span array, ulong* dest) { var arrayLength = array.Length; for (var i = 0; i < arrayLength; i++) dest[i] = (ulong) (array[i] ? 1 : 0); } } }