You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/04/21 13:49:34 UTC
svn commit: r936269 - in /pivot/trunk/core/src/org/apache/pivot/collections:
ArrayList.java LinkedList.java
Author: gbrown
Date: Wed Apr 21 11:49:34 2010
New Revision: 936269
URL: http://svn.apache.org/viewvc?rev=936269&view=rev
Log:
Resolve issue PIVOT-476.
Modified:
pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java
pivot/trunk/core/src/org/apache/pivot/collections/LinkedList.java
Modified: pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java?rev=936269&r1=936268&r2=936269&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java Wed Apr 21 11:49:34 2010
@@ -455,20 +455,22 @@ public class ArrayList<T> implements Lis
public boolean equals(Object o) {
boolean equals = false;
- if (o instanceof ArrayList<?>) {
- ArrayList<T> arrayList = (ArrayList<T>)o;
-
- if (arrayList.getLength() == length) {
- Iterator<T> iterator = iterator();
- Iterator<T> arrayListIterator = arrayList.iterator();
-
- while (iterator.hasNext()
- && arrayListIterator.hasNext()
- && equals) {
- equals &= iterator.next().equals(arrayListIterator.next());
+ if (this == o) {
+ equals = true;
+ } else if (o instanceof List) {
+ List<T> list = (List)o;
+
+ if (length == list.getLength()) {
+ Iterator<T> iterator = list.iterator();
+ equals = true;
+
+ for (T element : this) {
+ if (!(iterator.hasNext()
+ && element.equals(iterator.next()))) {
+ equals = false;
+ break;
+ }
}
- } else {
- equals = false;
}
}
Modified: pivot/trunk/core/src/org/apache/pivot/collections/LinkedList.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/LinkedList.java?rev=936269&r1=936268&r2=936269&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/LinkedList.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/LinkedList.java Wed Apr 21 11:49:34 2010
@@ -604,20 +604,22 @@ public class LinkedList<T> implements Li
public boolean equals(Object o) {
boolean equals = false;
- if (o instanceof LinkedList<?>) {
- LinkedList<T> linkedList = (LinkedList<T>)o;
-
- if (getLength() == linkedList.getLength()) {
- Iterator<T> iterator = iterator();
- Iterator<T> linkedListIterator = linkedList.iterator();
-
- while (iterator.hasNext()
- && linkedListIterator.hasNext()
- && equals) {
- equals &= iterator.next().equals(linkedListIterator.next());
+ if (this == o) {
+ equals = true;
+ } else if (o instanceof List) {
+ List<T> otherList = (List) o;
+
+ if (length == otherList.getLength()) {
+ Iterator<T> iterator = otherList.iterator();
+ equals = true;
+
+ for (T element : this) {
+ if (!(iterator.hasNext()
+ && element.equals(iterator.next()))) {
+ equals = false;
+ break;
+ }
}
- } else {
- equals = false;
}
}