예제 #1
0
 @Override
 public int compare(Object A_obj, Object B_obj) {
   if (A_obj instanceof BaseEntry && B_obj instanceof BaseEntry) {
     BaseEntry A = (BaseEntry) A_obj, B = (BaseEntry) B_obj;
     // If A has more features, it is greater.
     if (A.AttributeList.size() != B.AttributeList.size())
       return (A.AttributeList.size() > B.AttributeList.size()) ? 1 : -1;
     // Check which has greater features
     for (int i = 0; i < A.AttributeList.size(); i++)
       if (A.getAttribute(i) != B.getAttribute(i))
         return (A.getAttribute(i) > B.getAttribute(i)) ? 1 : -1;
     // We have concluded they are equal
     return 0;
   } else return 0;
 }
예제 #2
0
 /**
  * Generates a clone of an entry. It creates a new list to store the attributes. So, the attribute
  * data is preserved, but you can change the list as desired.
  *
  * @return Clone
  */
 @Override
 public BaseEntry clone() {
   BaseEntry copy;
   try {
     copy = (BaseEntry) super.clone();
   } catch (CloneNotSupportedException c) {
     throw new Error(c);
   }
   copy.AttributeList = new ArrayList<>(AttributeList);
   copy.Class = this.Class;
   copy.PredictedClass = this.PredictedClass;
   copy.measured = this.measured;
   copy.predicted = this.predicted;
   return copy;
 }