diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/intent/model/Node.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/intent/model/Node.java | 13 |
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 |