ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CopyOnWriteArrayList.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CopyOnWriteArrayList.java (file contents):
Revision 1.56 by jsr166, Wed Sep 14 22:52:49 2005 UTC vs.
Revision 1.57 by dl, Sun Sep 25 13:10:30 2005 UTC

# Line 66 | Line 66 | public class CopyOnWriteArrayList<E>
66      /** The array, accessed only via getArray/setArray. */
67      private volatile transient Object[] array;
68  
69 <    Object[]  getArray()           { return array; }
70 <    void      setArray(Object[] a) { array = a; }
69 >    /**
70 >     * Get the array. Non-private so as to also be accessible
71 >     * from CopyOnWriteArraySet class
72 >     */
73 >    final Object[]  getArray() {
74 >        return array;
75 >    }
76 >
77 >    /**
78 >     * Set the array
79 >     */
80 >    final void setArray(Object[] a) {
81 >        array = a;
82 >    }
83  
84      /**
85       * Creates an empty list.
# Line 861 | Line 873 | public class CopyOnWriteArrayList<E>
873  
874      /**
875       * Compares the specified object with this list for equality.
876 <     * Returns true if and only if the specified object is also a {@link
877 <     * List}, both lists have the same size, and all corresponding pairs
878 <     * of elements in the two lists are <em>equal</em>.  (Two elements
879 <     * <tt>e1</tt> and <tt>e2</tt> are <em>equal</em> if <tt>(e1==null ?
880 <     * e2==null : e1.equals(e2))</tt>.)  In other words, two lists are
881 <     * defined to be equal if they contain the same elements in the same
870 <     * order.
876 >     * Returns true if and only if the specified object is also a
877 >     * {@link List}, and every element of the specified list, as
878 >     * revealed by a single traversal of its <tt>iterator()</tt>, is
879 >     * also present in the same position of this list at the point of
880 >     * call of this method, and no other elements not present in the
881 >     * given list are contained in this list.
882       *
883       * @param o the object to be compared for equality with this list
884       * @return <tt>true</tt> if the specified object is equal to this list
# Line 878 | Line 889 | public class CopyOnWriteArrayList<E>
889          if (!(o instanceof List))
890              return false;
891  
881        Object[] elements = getArray();
892          List<?> list = (List<?>)(o);
893 <        if (elements.length != list.size())
893 >        Iterator<?> listIt = list.listIterator();
894 >        Object[] elements = getArray();
895 >        int len = elements.length;
896 >        for (int i = 0; i < len; ++i) {
897 >            if (!listIt.hasNext() || !eq(elements[i], listIt.next()))
898 >                return false;
899 >        }
900 >        if (listIt.hasNext())
901              return false;
885
886        Iterator<?> it = list.listIterator();
887        for (Object element : elements)
888            if (! eq(element, it.next()))
889                return false;
902          return true;
903      }
904  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines