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.109 by jsr166, Tue Feb 17 18:55:39 2015 UTC vs.
Revision 1.110 by jsr166, Sat Feb 21 20:36:26 2015 UTC

# Line 678 | Line 678 | public class PriorityBlockingQueue<E> ex
678          }
679      }
680  
681    /**
682     * Returns an array containing all of the elements in this queue.
683     * The returned array elements are in no particular order.
684     *
685     * <p>The returned array will be "safe" in that no references to it are
686     * maintained by this queue.  (In other words, this method must allocate
687     * a new array).  The caller is thus free to modify the returned array.
688     *
689     * <p>This method acts as bridge between array-based and collection-based
690     * APIs.
691     *
692     * @return an array containing all of the elements in this queue
693     */
694    public Object[] toArray() {
695        final ReentrantLock lock = this.lock;
696        lock.lock();
697        try {
698            return Arrays.copyOf(queue, size);
699        } finally {
700            lock.unlock();
701        }
702    }
703
681      public String toString() {
682          final ReentrantLock lock = this.lock;
683          lock.lock();
# Line 775 | Line 752 | public class PriorityBlockingQueue<E> ex
752          } finally {
753              lock.unlock();
754          }
755 +    }
756 +
757 +    /**
758 +     * Returns an array containing all of the elements in this queue.
759 +     * The returned array elements are in no particular order.
760 +     *
761 +     * <p>The returned array will be "safe" in that no references to it are
762 +     * maintained by this queue.  (In other words, this method must allocate
763 +     * a new array).  The caller is thus free to modify the returned array.
764 +     *
765 +     * <p>This method acts as bridge between array-based and collection-based
766 +     * APIs.
767 +     *
768 +     * @return an array containing all of the elements in this queue
769 +     */
770 +    public Object[] toArray() {
771 +        final ReentrantLock lock = this.lock;
772 +        lock.lock();
773 +        try {
774 +            return Arrays.copyOf(queue, size);
775 +        } finally {
776 +            lock.unlock();
777 +        }
778      }
779  
780      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines