diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d0010c..184ace79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] - 2026-07-07 +## [Unreleased] - 2026-07-28 ### Added ### Changed +* Refactored Permutation.equals() method (non-breaking). ### Deprecated diff --git a/src/main/java/org/cicirello/permutations/Permutation.java b/src/main/java/org/cicirello/permutations/Permutation.java index 24b2c507..86e62207 100644 --- a/src/main/java/org/cicirello/permutations/Permutation.java +++ b/src/main/java/org/cicirello/permutations/Permutation.java @@ -1,6 +1,6 @@ /* * JavaPermutationTools: A Java library for computation on permutations and sequences - * Copyright 2005-2024 Vincent A. Cicirello, . + * Copyright 2005-2026 Vincent A. Cicirello, . * * This file is part of JavaPermutationTools (https://jpt.cicirello.org/). * @@ -917,15 +917,10 @@ public String toString() { */ @Override public boolean equals(Object other) { - if (this == other) return true; - if (other == null) return false; - if (!(other instanceof Permutation)) return false; - Permutation o = (Permutation) other; - if (permutation.length != o.permutation.length) return false; - for (int i = 0; i < permutation.length; i++) { - if (permutation[i] != o.permutation[i]) return false; + if (other instanceof Permutation o) { + return Arrays.equals(permutation, o.permutation); } - return true; + return false; } /**