예제 #1
0
  /**
   * Compares the specified Object with the receiver. Returns true if and only if the specified
   * Object is also an ArrayList of the same type, both Lists have the same size, and all
   * corresponding pairs of elements in the two Lists are identical. In other words, two Lists are
   * defined to be equal if they contain the same elements in the same order.
   *
   * @param otherObj the Object to be compared for equality with the receiver.
   * @return true if the specified Object is equal to the receiver.
   */
  public boolean equals(Object otherObj) { // delta
    if (otherObj == null) {
      return false;
    }
    // overridden for performance only.
    if (!(otherObj instanceof FloatArrayList)) {
      return super.equals(otherObj);
    }
    if (this == otherObj) {
      return true;
    }
    FloatArrayList other = (FloatArrayList) otherObj;
    if (size() != other.size()) {
      return false;
    }

    float[] theElements = elements();
    float[] otherElements = other.elements();
    for (int i = size(); --i >= 0; ) {
      if (theElements[i] != otherElements[i]) {
        return false;
      }
    }
    return true;
  }