550 |
|
a[0] = null; |
551 |
|
return a; |
552 |
|
} |
553 |
+ |
|
554 |
+ |
|
555 |
+ |
public int drainTo(Collection<? super E> c) { |
556 |
+ |
if (c == null) |
557 |
+ |
throw new NullPointerException(); |
558 |
+ |
if (c == this) |
559 |
+ |
throw new IllegalArgumentException(); |
560 |
+ |
int n = 0; |
561 |
+ |
E e; |
562 |
+ |
while ( (e = poll()) != null) { |
563 |
+ |
c.add(e); |
564 |
+ |
++n; |
565 |
+ |
} |
566 |
+ |
return n; |
567 |
+ |
} |
568 |
+ |
|
569 |
+ |
public int drainTo(Collection<? super E> c, int maxElements) { |
570 |
+ |
if (c == null) |
571 |
+ |
throw new NullPointerException(); |
572 |
+ |
if (c == this) |
573 |
+ |
throw new IllegalArgumentException(); |
574 |
+ |
int n = 0; |
575 |
+ |
E e; |
576 |
+ |
while (n < maxElements && (e = poll()) != null) { |
577 |
+ |
c.add(e); |
578 |
+ |
++n; |
579 |
+ |
} |
580 |
+ |
return n; |
581 |
+ |
} |
582 |
|
} |
583 |
|
|
584 |
|
|