Skip to content

Commit

Permalink
Equals/Hashcode for DNNF data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
czengler committed Feb 4, 2024
1 parent a90abda commit 5eb5ef2
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -79,4 +80,21 @@ public Formula formula() {
public SortedSet<Variable> 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);
}
}

0 comments on commit 5eb5ef2

Please sign in to comment.