Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SequenceEqual< T >() [2/4]

static bool System.MemoryExtensions.SequenceEqual< T > ( this ReadOnlySpan< T > span,
ReadOnlySpan< T > other,
IEqualityComparer< T >? comparer = null )
inlinestatic

Definition at line 878 of file MemoryExtensions.cs.

879 {
880 if (span.Length != other.Length)
881 {
882 return false;
883 }
884 if (typeof(T).IsValueType && (comparer == null || comparer == EqualityComparer<T>.Default))
885 {
886 if (RuntimeHelpers.IsBitwiseEquatable<T>())
887 {
888 nuint num = (nuint)Unsafe.SizeOf<T>();
889 return SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), (uint)span.Length * num);
890 }
891 for (int i = 0; i < span.Length; i++)
892 {
893 if (!EqualityComparer<T>.Default.Equals(span[i], other[i]))
894 {
895 return false;
896 }
897 }
898 return true;
899 }
900 if (comparer == null)
901 {
903 }
904 for (int j = 0; j < span.Length; j++)
905 {
906 if (!comparer.Equals(span[j], other[j]))
907 {
908 return false;
909 }
910 }
911 return true;
912 }

References System.comparer, System.Default, System.other, System.SpanHelpers.SequenceEqual(), and System.T.