From 5eb5ef246df40afcc30bfed0f005071e6983c98f Mon Sep 17 00:00:00 2001 From: Christoph Zengler Date: Sun, 4 Feb 2024 20:43:35 +0100 Subject: [PATCH] Equals/Hashcode for DNNF data structure --- .../dnnf/datastructures/Dnnf.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/logicng/knowledgecompilation/dnnf/datastructures/Dnnf.java b/src/main/java/org/logicng/knowledgecompilation/dnnf/datastructures/Dnnf.java index 4a2dea46..1b2f964b 100644 --- a/src/main/java/org/logicng/knowledgecompilation/dnnf/datastructures/Dnnf.java +++ b/src/main/java/org/logicng/knowledgecompilation/dnnf/datastructures/Dnnf.java @@ -32,11 +32,12 @@ import org.logicng.formulas.Variable; import org.logicng.knowledgecompilation.dnnf.functions.DnnfFunction; +import java.util.Objects; import java.util.SortedSet; /** * A DNNF - Decomposable Negation Normal Form. - * @version 2.0.0 + * @version 2.5.0 * @since 2.0.0 */ public final class Dnnf { @@ -79,4 +80,21 @@ public Formula formula() { public SortedSet getOriginalVariables() { return this.originalVariables; } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Dnnf dnnf = (Dnnf) o; + return Objects.equals(this.originalVariables, dnnf.originalVariables) && Objects.equals(this.formula, dnnf.formula); + } + + @Override + public int hashCode() { + return Objects.hash(this.originalVariables, this.formula); + } }