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; }
@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; }