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

Comparing jsr166/src/main/java/util/concurrent/PriorityBlockingQueue.java (file contents):
Revision 1.25 by dl, Sat Sep 20 00:31:08 2003 UTC vs.
Revision 1.26 by dl, Sun Oct 5 23:00:18 2003 UTC

# Line 296 | Line 296 | public class PriorityBlockingQueue<E> ex
296          }
297      }
298  
299 +    public int drainTo(Collection<? super E> c) {
300 +        if (c == null)
301 +            throw new NullPointerException();
302 +        if (c == this)
303 +            throw new IllegalArgumentException();
304 +        lock.lock();
305 +        try {
306 +            int n = 0;
307 +            E e;
308 +            while ( (e = q.poll()) != null) {
309 +                c.add(e);
310 +                ++n;
311 +            }
312 +            return n;
313 +        } finally {
314 +            lock.unlock();
315 +        }
316 +    }
317 +
318 +    public int drainTo(Collection<? super E> c, int maxElements) {
319 +        if (c == null)
320 +            throw new NullPointerException();
321 +        if (c == this)
322 +            throw new IllegalArgumentException();
323 +        if (maxElements <= 0)
324 +            return 0;
325 +        lock.lock();
326 +        try {
327 +            int n = 0;
328 +            E e;
329 +            while (n < maxElements && (e = q.poll()) != null) {
330 +                c.add(e);
331 +                ++n;
332 +            }
333 +            return n;
334 +        } finally {
335 +            lock.unlock();
336 +        }
337 +    }
338 +
339      /**
340       * Atomically removes all of the elements from this delay queue.
341       * The queue will be empty after this call returns.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines