1 |
|
/* |
2 |
|
* %W% %E% |
3 |
|
* |
4 |
< |
* Copyright 2005 Sun Microsystems, Inc. All rights reserved. |
4 |
> |
* Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
5 |
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
6 |
|
*/ |
7 |
|
|
2221 |
|
public Object[] toArray() { return c.toArray(); } |
2222 |
|
public <T> T[] toArray(T[] a) { return c.toArray(a); } |
2223 |
|
public String toString() { return c.toString(); } |
2224 |
– |
public Iterator<E> iterator() { return c.iterator(); } |
2224 |
|
public boolean remove(Object o) { return c.remove(o); } |
2225 |
|
public boolean containsAll(Collection<?> coll) { |
2226 |
|
return c.containsAll(coll); |
2235 |
|
c.clear(); |
2236 |
|
} |
2237 |
|
|
2238 |
< |
public boolean add(E e){ |
2238 |
> |
public Iterator<E> iterator() { |
2239 |
> |
return new Iterator<E>() { |
2240 |
> |
private final Iterator<E> it = c.iterator(); |
2241 |
> |
public boolean hasNext() { return it.hasNext(); } |
2242 |
> |
public E next() { return it.next(); } |
2243 |
> |
public void remove() { it.remove(); }}; |
2244 |
> |
} |
2245 |
> |
|
2246 |
> |
public boolean add(E e){ |
2247 |
|
typeCheck(e); |
2248 |
|
return c.add(e); |
2249 |
|
} |
3505 |
|
* </pre> |
3506 |
|
* |
3507 |
|
* @param c the collection into which <tt>elements</tt> are to be inserted |
3508 |
< |
* @param a the elements to insert into <tt>c</tt> |
3508 |
> |
* @param elements the elements to insert into <tt>c</tt> |
3509 |
|
* @return <tt>true</tt> if the collection changed as a result of the call |
3510 |
|
* @throws UnsupportedOperationException if <tt>c</tt> does not support |
3511 |
< |
* the <tt>add</tt> operation. |
3511 |
> |
* the <tt>add</tt> operation |
3512 |
|
* @throws NullPointerException if <tt>elements</tt> contains one or more |
3513 |
|
* null values and <tt>c</tt> does not permit null elements, or |
3514 |
|
* if <tt>c</tt> or <tt>elements</tt> are <tt>null</tt> |
3517 |
|
* @see Collection#addAll(Collection) |
3518 |
|
* @since 1.5 |
3519 |
|
*/ |
3520 |
< |
public static <T> boolean addAll(Collection<? super T> c, T... a) { |
3520 |
> |
public static <T> boolean addAll(Collection<? super T> c, T... elements) { |
3521 |
|
boolean result = false; |
3522 |
< |
for (T e : a) |
3523 |
< |
result |= c.add(e); |
3522 |
> |
for (T element : elements) |
3523 |
> |
result |= c.add(element); |
3524 |
|
return result; |
3525 |
|
} |
3526 |
|
|
3607 |
|
* <tt>remove</tt> is mapped to <tt>pop</tt> and so on. This |
3608 |
|
* view can be useful when you would like to use a method |
3609 |
|
* requiring a <tt>Queue</tt> but you need Lifo ordering. |
3610 |
+ |
* |
3611 |
|
* @param deque the deque |
3612 |
|
* @return the queue |
3613 |
|
* @since 1.6 |
3621 |
|
private static final long serialVersionUID = 1802017725587941708L; |
3622 |
|
private final Deque<E> q; |
3623 |
|
AsLIFOQueue(Deque<E> q) { this.q = q; } |
3624 |
+ |
public boolean add(E e) { q.addFirst(e); return true; } |
3625 |
|
public boolean offer(E e) { return q.offerFirst(e); } |
3626 |
|
public E poll() { return q.pollFirst(); } |
3627 |
|
public E remove() { return q.removeFirst(); } |
3633 |
|
public Iterator<E> iterator() { return q.iterator(); } |
3634 |
|
public Object[] toArray() { return q.toArray(); } |
3635 |
|
public <T> T[] toArray(T[] a) { return q.toArray(a); } |
3627 |
– |
public boolean add(E e) { return q.offerFirst(e); } |
3636 |
|
public boolean remove(Object o) { return q.remove(o); } |
3637 |
|
public void clear() { q.clear(); } |
3638 |
|
} |