summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/intent
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-09-17 14:40:43 +0200
committerJon Bratseth <bratseth@verizonmedia.com>2019-09-17 14:40:43 +0200
commit7c4e91a3f4f2553dea73ed4e230bd74655c7736e (patch)
tree575e852394594bbb2a431bef568e6da7618b76f4 /container-search/src/main/java/com/yahoo/search/intent
parentfb4b666e78d936d0f6aadcc4f74cf208e8056776 (diff)
Add equals and cleanup
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/intent')
-rw-r--r--container-search/src/main/java/com/yahoo/search/intent/model/Node.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/intent/model/Node.java b/container-search/src/main/java/com/yahoo/search/intent/model/Node.java
index 98bfd588004..84b90b388b0 100644
--- a/container-search/src/main/java/com/yahoo/search/intent/model/Node.java
+++ b/container-search/src/main/java/com/yahoo/search/intent/model/Node.java
@@ -32,12 +32,25 @@ public abstract class Node implements Comparable<Node> {
return getScore();
}
+ @Override
public int compareTo(Node other) {
if (this.getScore() < other.getScore()) return 1;
if (this.getScore() > other.getScore()) return -1;
return 0;
}
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) return true;
+ if ( ! (other instanceof Node)) return false;
+ return this.getScore() == ((Node)other).getScore();
+ }
+
+ @Override
+ public int hashCode() {
+ return Double.hashCode(getScore());
+ }
+
/**
* Adds the sources at (and beneath) this node to the given
* sparsely represented source vector, weighted by the score of this node