Beispiel #1
0
 /**
  * Check is two complex are equals
  *
  * @param c complex to compare
  * @return boolean True if are equals. False otherwise
  */
 public boolean isEqual(Complex c) {
   boolean bEquals = false;
   if (c.size() == compl.size()) {
     bEquals = true;
     for (int i = 0; (i < c.size()) && (bEquals); i++) {
       bEquals = (this.getSelector(i).compareTo(c.getSelector(i)) == 0);
     }
   }
   return bEquals;
 }
Beispiel #2
0
  /**
   * Compare two objects of the Complex class
   *
   * @param o Object Complex to compare
   * @return int 0 if are equals (same heuristic and size, -1 if is better (same heuristic less size
   *     || high heuristic) 1 if is worst (same heuristic, high size || less heuristic).
   */
  public int compareTo(Object o) {
    Complex c2 = (Complex) o;
    int out = 0;

    if (heuristic == c2.getHeuristic() && compl.size() == c2.size()) {
      out = 0;
    } else if (heuristic == c2.getHeuristic() && compl.size() < c2.size()) {
      out = -1;
    } else if (heuristic == c2.getHeuristic() && compl.size() > c2.size()) {
      out = 1;
    } else if (heuristic > c2.getHeuristic()) {
      out = -1;
    } else if (heuristic < c2.getHeuristic()) {
      out = 1;
    }

    return (out);
  }