Ejemplo n.º 1
0
        public static int GetHashCode <T>(T?value)
        {
            var pValue = Unsafe.AsPointer(ref value);
            var size   = Unsafe.SizeOf <T>();

            return(BinaryEqualityComparer.GetHashCode(pValue, size));
        }
Ejemplo n.º 2
0
        public static bool Equals <T>(T?value, T?other)
        {
            var pValue = Unsafe.AsPointer(ref value);
            var pOther = Unsafe.AsPointer(ref other);
            var size   = Unsafe.SizeOf <T>();

            return(BinaryEqualityComparer.Equals(pValue, pOther, size));
        }
Ejemplo n.º 3
0
        public static int GetBinaryHashCode <T>(this T[, , ]?array) where T : unmanaged
        {
            if (array is null)
            {
                return(0);
            }

            fixed(T *pArray = array)
            {
                var size = sizeof(T) * array.Length;

                return(BinaryEqualityComparer.GetHashCode(pArray, size));
            }
        }
Ejemplo n.º 4
0
        public static bool BinaryEquals <T>(this ReadOnlySpan <T> span, ReadOnlySpan <T> other)
            where T : unmanaged
        {
            if (span == other)
            {
                return(true);
            }
            if (span.Length != other.Length)
            {
                return(false);
            }

            fixed(T *pSpan = span, pOther = other)
            {
                var size = sizeof(T) * span.Length;

                return(BinaryEqualityComparer.Equals(pSpan, pOther, size));
            }
        }
Ejemplo n.º 5
0
        public static bool BinaryEquals <T>(this T[, , ]?array, T[, , ]?other) where T : unmanaged
        {
            if (object.ReferenceEquals(array, other))
            {
                return(true);
            }
            if ((array is null) || (other is null))
            {
                return(false);
            }
            if (array.Length != other.Length)
            {
                return(false);
            }

            fixed(T *pArray = array, pOther = other)
            {
                var size = sizeof(T) * array.Length;

                return(BinaryEqualityComparer.Equals(pArray, pOther, size));
            }
        }
Ejemplo n.º 6
0
 public static int GetBinaryHashCode <T>(this T value) where T : unmanaged
 {
     return(BinaryEqualityComparer.GetHashCode(&value, sizeof(T)));
 }
Ejemplo n.º 7
0
 public static bool BinaryEquals <T>(this T value, T other) where T : unmanaged
 {
     return(BinaryEqualityComparer.Equals(&value, &other, sizeof(T)));
 }