using System; using System.Runtime.InteropServices; namespace SharpGen.Runtime { public static 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, Span dest) => MemoryMarshal.AsBytes(array).CopyTo(dest); /// /// Converts bool array to an array of integers. /// /// The bool 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 bool array to an array of integers. /// /// The bool 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 bool array to an array of integers. /// /// The bool 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 bool array to an array of integers. /// /// The bool array. /// The destination array of integers. public static void ConvertToIntArray(Span array, Span dest) => MemoryMarshal.AsBytes(array).CopyTo(MemoryMarshal.AsBytes(dest)); /// /// Converts bool array to an array of integers. /// /// The bool 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 bool array to an array of integers. /// /// The bool 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] = (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, Span dest) { var arrayLength = array.Length; for (var i = 0; i < arrayLength; i++) dest[i] = (ulong) (array[i] ? 1 : 0); } } }