diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-09-10 10:58:09 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-09-10 10:58:09 +0200 |
commit | 440a39081e32ad634eb27ebfa5eb31b84f9c39e6 (patch) | |
tree | 15b28f3bc6e670a0b130e32174c7ed124cbe7d96 /document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java | |
parent | 79fbe75a324084d7e871e4aa7b82500e7ccd35b3 (diff) |
Before compareTo on a hashmap makes sense it must be sorted.
Diffstat (limited to 'document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java')
-rw-r--r-- | document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java b/document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java index 0e4c56406f0..63dc1cab063 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java +++ b/document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java @@ -241,8 +241,7 @@ public final class WeightedSet<K extends FieldValue> extends CollectionFieldValu */ public boolean equals(Object o) { if (!(o instanceof WeightedSet)) return false; - WeightedSet otherSet = (WeightedSet) o; - return (super.equals(o) && map.equals(otherSet.map)); + return (super.equals(o) && map.equals(((WeightedSet<K>)o).map)); } /** @@ -293,15 +292,7 @@ public final class WeightedSet<K extends FieldValue> extends CollectionFieldValu return comp; } - //types are equal, this must be of this type - WeightedSet otherValue = (WeightedSet) fieldValue; - comp = CollectionComparator.compare(map.keySet(), otherValue.map.keySet()); - - if (comp != 0) { - return comp; - } - - return CollectionComparator.compare(map.values(), otherValue.map.values()); + return map.compareTo(((WeightedSet<K>)fieldValue).map); } |