Ejemplo n.º 1
0
 public boolean equals(Object obj) {
   if (obj == null) {
     return _size() <= start;
   }
   if (obj instanceof AMList) {
     AMList o = (AMList) obj;
     int cnt = _size();
     if (cnt - start != o._size() - o.start) {
       return false;
     }
     Object[] arr = array(), arr_ = o.array();
     for (int i = start, j = o.start; i < cnt; ++i, ++j) {
       Object a = arr[i], b = arr_[j];
       if (a != b && (a == null || !a.equals(b))) {
         return false;
       }
     }
     return true;
   }
   if (!(obj instanceof AList)) {
     return false;
   }
   Object[] array = array();
   AIter j = (AList) obj;
   Object x, y;
   for (int cnt = _size(), i = start; i < cnt; ++i) {
     if (j == null || (x = array[i]) != (y = j.first()) && (x == null || !x.equals(y))) {
       return false;
     }
     j = j.next();
   }
   return j == null;
 }
Ejemplo n.º 2
0
 public int compareTo(Object other) {
   AMList o = (AMList) other;
   Object[] array = array();
   Object[] array_ = o.array();
   int cnt = _size(), cnt_ = o._size();
   for (int r, i = start, j = o.start; i < cnt && j < cnt_; ++i, ++j) {
     Object a, b;
     if ((b = array_[j]) != (a = array[i])) {
       if (a == null) {
         return -1;
       }
       if (b == null) {
         return 1;
       }
       if ((r = ((Comparable) a).compareTo(b)) != 0) {
         return r;
       }
     }
   }
   return cnt < cnt_ ? -1 : cnt > cnt_ ? 1 : 0;
 }