コード例 #1
0
  public Object clone() throws CloneNotSupportedException {
    LinkedListVector clone = (LinkedListVector) super.clone();
    Node cursor = head;

    for (int i = 0; i < size(); i++) {
      clone.add(cursor.value);
      cursor = cursor.next;
    }

    clone.size = size();
    return clone;
  }
コード例 #2
0
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    LinkedListVector that = (LinkedListVector) o;

    if (size != that.size()) {
      return false;
    }

    for (int i = 0; i < size(); i++) {
      if (get(i) != that.get(i)) {
        return false;
      }
    }

    return true;
  }