Skip to content

DenseMatrix<T>.GetHashCode is incorrect #1116

@antonfirsov

Description

@antonfirsov

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

DenseMatrix<T> equality + hash code is incorrect:

       public bool Equals(DenseMatrix<T> other) =>
            this.Columns == other.Columns
            && this.Rows == other.Rows
            && this.Span.SequenceEqual(other.Span);

        /// <inheritdoc/>
        public override int GetHashCode() => this.Data.GetHashCode();

For matrices having same content but different arrays a.Equals(b) == true, but a.GetHashCode() != b.GetHashCode(), which is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions