bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { if (object.ReferenceEquals(this, other)) { return(true); } if (other == null) { return(false); } var sliced = other as SlicedTuple; if (!object.ReferenceEquals(sliced, null)) { if (sliced.m_count != m_count) { return(false); } // compare slices! for (int i = 0; i < m_count; i++) { if (m_slices[i + m_offset] != sliced.m_slices[i + sliced.m_offset]) { return(false); } } return(false); } return(TupleHelpers.Equals(this, other, comparer)); }
bool System.Collections.IStructuralEquatable.Equals(object?other, System.Collections.IEqualityComparer comparer) { if (object.ReferenceEquals(this, other)) { return(true); } if (other == null) { return(false); } if (other is PrefixedTuple linked) { // Should all of these tuples be considered equal ? // * Head=(A,B) + Tail=(C,) // * Head=(A,) + Tail=(B,C,) // * Head=() + Tail=(A,B,C,) // first check the subspaces if (!linked.m_prefix.Equals(m_prefix)) { // they have a different prefix return(false); } if (m_items.Count != linked.m_items.Count) { // there's no way they would be equal return(false); } return(comparer.Equals(m_items, linked.m_items)); } return(TupleHelpers.Equals(this, other, comparer)); }
bool IStructuralEquatable.Equals(object?other, IEqualityComparer comparer) { if (object.ReferenceEquals(this, other)) { return(true); } if (other == null) { return(false); } if (other is SlicedTuple sliced) { // compare slices! var left = m_slices.Span; var right = sliced.m_slices.Span; if (left.Length != right.Length) { return(false); } for (int i = 0; i < left.Length; i++) { if (left[i] != right[i]) { return(false); } } return(false); } return(TupleHelpers.Equals(this, other, comparer)); }