示例#1
0
 /**
  * Compare the distance values to allow sorting in a tree map. If the distance value is the same,
  * but the document is different, the index number within the index is used to distinguishing the
  * results. Otherwise the TreeMap implementation wouldn't add the result.
  *
  * @param o the SimpleResult to compare the current one to.
  * @return -1, 0, or 1
  */
 public int compareTo(SimpleResult o) {
   int compareValue = (int) Math.signum(distance - ((SimpleResult) o).distance);
   if (compareValue == 0 && !document.equals(o.document)) {
     return (int) Math.signum(indexNumber - o.indexNumber);
   }
   return compareValue;
 }
示例#2
0
 @Override
 public boolean equals(Object obj) {
   // it's not the same if it's not the same class.
   if (!(obj instanceof SimpleResult)) return false;
   // it's the same if the document is the same, regardless of the distance.
   else
     return (document.equals(((SimpleResult) obj).document)
         && indexNumber == ((SimpleResult) obj).indexNumber);
 }