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

Comparing jsr166/src/main/java/util/Collections.java (file contents):
Revision 1.18 by jsr166, Mon Dec 5 02:56:59 2005 UTC vs.
Revision 1.21 by jsr166, Tue Feb 7 20:54:24 2006 UTC

# Line 6 | Line 6
6   */
7  
8   package java.util;
9 import java.util.*; // for javadoc (till 6280605 is fixed)
9   import java.io.Serializable;
10   import java.io.ObjectOutputStream;
11   import java.io.IOException;
# Line 2221 | Line 2220 | public class Collections {
2220          public Object[] toArray()           { return c.toArray(); }
2221          public <T> T[] toArray(T[] a)       { return c.toArray(a); }
2222          public String toString()            { return c.toString(); }
2224        public Iterator<E> iterator()       { return c.iterator(); }
2223          public boolean remove(Object o)     { return c.remove(o); }
2224          public boolean containsAll(Collection<?> coll) {
2225              return c.containsAll(coll);
# Line 2236 | Line 2234 | public class Collections {
2234              c.clear();
2235          }
2236  
2237 <        public boolean add(E e){
2237 >        public Iterator<E> iterator() {
2238 >            return new Iterator<E>() {
2239 >                private final Iterator<E> it = c.iterator();
2240 >                public boolean hasNext() { return it.hasNext(); }
2241 >                public E next()          { return it.next(); }
2242 >                public void remove()     {        it.remove(); }};
2243 >        }
2244 >
2245 >        public boolean add(E e){
2246              typeCheck(e);
2247              return c.add(e);
2248          }
# Line 3498 | Line 3504 | public class Collections {
3504       * </pre>
3505       *
3506       * @param c the collection into which <tt>elements</tt> are to be inserted
3507 <     * @param a the elements to insert into <tt>c</tt>
3507 >     * @param elements the elements to insert into <tt>c</tt>
3508       * @return <tt>true</tt> if the collection changed as a result of the call
3509       * @throws UnsupportedOperationException if <tt>c</tt> does not support
3510 <     *         the <tt>add</tt> operation.
3510 >     *         the <tt>add</tt> operation
3511       * @throws NullPointerException if <tt>elements</tt> contains one or more
3512       *         null values and <tt>c</tt> does not permit null elements, or
3513       *         if <tt>c</tt> or <tt>elements</tt> are <tt>null</tt>
# Line 3510 | Line 3516 | public class Collections {
3516       * @see Collection#addAll(Collection)
3517       * @since 1.5
3518       */
3519 <    public static <T> boolean addAll(Collection<? super T> c, T... a) {
3519 >    public static <T> boolean addAll(Collection<? super T> c, T... elements) {
3520          boolean result = false;
3521 <        for (T e : a)
3522 <            result |= c.add(e);
3521 >        for (T element : elements)
3522 >            result |= c.add(element);
3523          return result;
3524      }
3525  
# Line 3614 | Line 3620 | public class Collections {
3620          private static final long serialVersionUID = 1802017725587941708L;
3621          private final Deque<E> q;
3622          AsLIFOQueue(Deque<E> q)            { this.q = q; }
3623 +        public boolean add(E e)            { q.addFirst(e); return true; }
3624          public boolean offer(E e)          { return q.offerFirst(e); }
3625          public E poll()                    { return q.pollFirst(); }
3626          public E remove()                  { return q.removeFirst(); }
# Line 3625 | Line 3632 | public class Collections {
3632          public Iterator<E> iterator()      { return q.iterator(); }
3633          public Object[] toArray()          { return q.toArray(); }
3634          public <T> T[] toArray(T[] a)      { return q.toArray(a); }
3628        public boolean add(E e)            { return q.offerFirst(e); }
3635          public boolean remove(Object o)    { return q.remove(o); }
3636          public void clear()                { q.clear(); }
3637      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines