59 |
|
* Items 0 ... n - 1. |
60 |
|
*/ |
61 |
|
private static LinkedBlockingDeque<Item> populatedDeque(int n) { |
62 |
< |
LinkedBlockingDeque<Item> q = |
63 |
< |
new LinkedBlockingDeque<Item>(n); |
62 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(n); |
63 |
|
assertTrue(q.isEmpty()); |
64 |
|
for (int i = 0; i < n; i++) |
65 |
|
mustOffer(q, i); |
75 |
|
* isEmpty is true before add, false after |
76 |
|
*/ |
77 |
|
public void testEmpty() { |
78 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
78 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
79 |
|
assertTrue(q.isEmpty()); |
80 |
|
q.add(one); |
81 |
|
assertFalse(q.isEmpty()); |
104 |
|
* offerFirst(null) throws NullPointerException |
105 |
|
*/ |
106 |
|
public void testOfferFirstNull() { |
107 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
107 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
108 |
|
try { |
109 |
|
q.offerFirst(null); |
110 |
|
shouldThrow(); |
115 |
|
* offerLast(null) throws NullPointerException |
116 |
|
*/ |
117 |
|
public void testOfferLastNull() { |
118 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
118 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
119 |
|
try { |
120 |
|
q.offerLast(null); |
121 |
|
shouldThrow(); |
126 |
|
* OfferFirst succeeds |
127 |
|
*/ |
128 |
|
public void testOfferFirst() { |
129 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
129 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
130 |
|
assertTrue(q.offerFirst(zero)); |
131 |
|
assertTrue(q.offerFirst(two)); |
132 |
|
} |
135 |
|
* OfferLast succeeds |
136 |
|
*/ |
137 |
|
public void testOfferLast() { |
138 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
138 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
139 |
|
assertTrue(q.offerLast(zero)); |
140 |
|
assertTrue(q.offerLast(one)); |
141 |
|
} |
389 |
|
*/ |
390 |
|
public void testConstructor6() { |
391 |
|
Item[] items = defaultItems; |
392 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(Arrays.asList(items)); |
392 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(Arrays.asList(items)); |
393 |
|
for (int i = 0; i < SIZE; ++i) |
394 |
|
mustEqual(items[i], q.poll()); |
395 |
|
} |
398 |
|
* Deque transitions from empty to full when elements added |
399 |
|
*/ |
400 |
|
public void testEmptyFull() { |
401 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(2); |
401 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(2); |
402 |
|
assertTrue(q.isEmpty()); |
403 |
|
mustEqual(2, q.remainingCapacity()); |
404 |
|
q.add(one); |
430 |
|
* push(null) throws NPE |
431 |
|
*/ |
432 |
|
public void testPushNull() { |
433 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(1); |
433 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(1); |
434 |
|
try { |
435 |
|
q.push(null); |
436 |
|
shouldThrow(); |
441 |
|
* push succeeds if not full; throws IllegalStateException if full |
442 |
|
*/ |
443 |
|
public void testPush() { |
444 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
444 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
445 |
|
for (int i = 0; i < SIZE; ++i) { |
446 |
|
Item x = itemFor(i); |
447 |
|
q.push(x); |
482 |
|
* Offer succeeds if not full; fails if full |
483 |
|
*/ |
484 |
|
public void testOffer() { |
485 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(1); |
485 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(1); |
486 |
|
assertTrue(q.offer(zero)); |
487 |
|
assertFalse(q.offer(one)); |
488 |
|
} |
491 |
|
* add succeeds if not full; throws IllegalStateException if full |
492 |
|
*/ |
493 |
|
public void testAdd() { |
494 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
494 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
495 |
|
for (int i = 0; i < SIZE; ++i) |
496 |
|
mustAdd(q, i); |
497 |
|
mustEqual(0, q.remainingCapacity()); |
517 |
|
* possibly adding some elements |
518 |
|
*/ |
519 |
|
public void testAddAll3() { |
520 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
520 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
521 |
|
Item[] items = new Item[2]; items[0] = zero; |
522 |
|
Collection<Item> elements = Arrays.asList(items); |
523 |
|
try { |
530 |
|
* addAll throws IllegalStateException if not enough room |
531 |
|
*/ |
532 |
|
public void testAddAll4() { |
533 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE - 1); |
533 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE - 1); |
534 |
|
Item[] items = defaultItems; |
535 |
|
Collection<Item> elements = Arrays.asList(items); |
536 |
|
try { |
545 |
|
public void testAddAll5() { |
546 |
|
Item[] empty = new Item[0]; |
547 |
|
Item[] items = defaultItems; |
548 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
548 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
549 |
|
assertFalse(q.addAll(Arrays.asList(empty))); |
550 |
|
assertTrue(q.addAll(Arrays.asList(items))); |
551 |
|
for (int i = 0; i < SIZE; ++i) |
556 |
|
* all elements successfully put are contained |
557 |
|
*/ |
558 |
|
public void testPut() throws InterruptedException { |
559 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
559 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
560 |
|
for (int i = 0; i < SIZE; ++i) { |
561 |
|
Item x = itemFor(i); |
562 |
|
q.put(x); |
569 |
|
* put blocks interruptibly if full |
570 |
|
*/ |
571 |
|
public void testBlockingPut() throws InterruptedException { |
572 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
572 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
573 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
574 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
575 |
|
public void realRun() throws InterruptedException { |
606 |
|
*/ |
607 |
|
public void testPutWithTake() throws InterruptedException { |
608 |
|
final int capacity = 2; |
609 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(capacity); |
609 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(capacity); |
610 |
|
final CountDownLatch pleaseTake = new CountDownLatch(1); |
611 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
612 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
646 |
|
* timed offer times out if full and elements not taken |
647 |
|
*/ |
648 |
|
public void testTimedOffer() { |
649 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(2); |
649 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(2); |
650 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
651 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
652 |
|
public void realRun() throws InterruptedException { |
795 |
|
* putFirst(null) throws NPE |
796 |
|
*/ |
797 |
|
public void testPutFirstNull() throws InterruptedException { |
798 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
798 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
799 |
|
try { |
800 |
|
q.putFirst(null); |
801 |
|
shouldThrow(); |
806 |
|
* all elements successfully putFirst are contained |
807 |
|
*/ |
808 |
|
public void testPutFirst() throws InterruptedException { |
809 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
809 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
810 |
|
for (int i = 0; i < SIZE; ++i) { |
811 |
|
Item x = itemFor(i); |
812 |
|
q.putFirst(x); |
819 |
|
* putFirst blocks interruptibly if full |
820 |
|
*/ |
821 |
|
public void testBlockingPutFirst() throws InterruptedException { |
822 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
822 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
823 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
824 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
825 |
|
public void realRun() throws InterruptedException { |
856 |
|
*/ |
857 |
|
public void testPutFirstWithTake() throws InterruptedException { |
858 |
|
final int capacity = 2; |
859 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(capacity); |
859 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(capacity); |
860 |
|
final CountDownLatch pleaseTake = new CountDownLatch(1); |
861 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
862 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
889 |
|
* timed offerFirst times out if full and elements not taken |
890 |
|
*/ |
891 |
|
public void testTimedOfferFirst() { |
892 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(2); |
892 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(2); |
893 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
894 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
895 |
|
public void realRun() throws InterruptedException { |
935 |
|
* takeFirst() blocks interruptibly when empty |
936 |
|
*/ |
937 |
|
public void testTakeFirstFromEmptyBlocksInterruptibly() { |
938 |
< |
final BlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
938 |
> |
final BlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
939 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
940 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
941 |
|
public void realRun() { |
958 |
|
* before waiting |
959 |
|
*/ |
960 |
|
public void testTakeFirstFromEmptyAfterInterrupt() { |
961 |
< |
final BlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
961 |
> |
final BlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
962 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
963 |
|
public void realRun() { |
964 |
|
Thread.currentThread().interrupt(); |
976 |
|
* takeLast() blocks interruptibly when empty |
977 |
|
*/ |
978 |
|
public void testTakeLastFromEmptyBlocksInterruptibly() { |
979 |
< |
final BlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
979 |
> |
final BlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
980 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
981 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
982 |
|
public void realRun() { |
999 |
|
* before waiting |
1000 |
|
*/ |
1001 |
|
public void testTakeLastFromEmptyAfterInterrupt() { |
1002 |
< |
final BlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
1002 |
> |
final BlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
1003 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
1004 |
|
public void realRun() { |
1005 |
|
Thread.currentThread().interrupt(); |
1109 |
|
* on interruption throws |
1110 |
|
*/ |
1111 |
|
public void testTimedPollFirstWithOfferFirst() throws InterruptedException { |
1112 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(2); |
1112 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(2); |
1113 |
|
final CheckedBarrier barrier = new CheckedBarrier(2); |
1114 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
1115 |
|
public void realRun() throws InterruptedException { |
1151 |
|
* putLast(null) throws NPE |
1152 |
|
*/ |
1153 |
|
public void testPutLastNull() throws InterruptedException { |
1154 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
1154 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
1155 |
|
try { |
1156 |
|
q.putLast(null); |
1157 |
|
shouldThrow(); |
1162 |
|
* all elements successfully putLast are contained |
1163 |
|
*/ |
1164 |
|
public void testPutLast() throws InterruptedException { |
1165 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
1165 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
1166 |
|
for (int i = 0; i < SIZE; ++i) { |
1167 |
|
Item x = itemFor(i); |
1168 |
|
q.putLast(x); |
1175 |
|
* putLast blocks interruptibly if full |
1176 |
|
*/ |
1177 |
|
public void testBlockingPutLast() throws InterruptedException { |
1178 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(SIZE); |
1178 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(SIZE); |
1179 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
1180 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
1181 |
|
public void realRun() throws InterruptedException { |
1212 |
|
*/ |
1213 |
|
public void testPutLastWithTake() throws InterruptedException { |
1214 |
|
final int capacity = 2; |
1215 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(capacity); |
1215 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(capacity); |
1216 |
|
final CountDownLatch pleaseTake = new CountDownLatch(1); |
1217 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
1218 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
1252 |
|
* timed offerLast times out if full and elements not taken |
1253 |
|
*/ |
1254 |
|
public void testTimedOfferLast() { |
1255 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(2); |
1255 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(2); |
1256 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
1257 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
1258 |
|
public void realRun() throws InterruptedException { |
1391 |
|
* on interruption throws |
1392 |
|
*/ |
1393 |
|
public void testTimedPollWithOfferLast() throws InterruptedException { |
1394 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(2); |
1394 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(2); |
1395 |
|
final CheckedBarrier barrier = new CheckedBarrier(2); |
1396 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
1397 |
|
public void realRun() throws InterruptedException { |
1479 |
|
*/ |
1480 |
|
public void testContainsAll() { |
1481 |
|
LinkedBlockingDeque<Item> q = populatedDeque(SIZE); |
1482 |
< |
LinkedBlockingDeque<Item> p = new LinkedBlockingDeque<Item>(SIZE); |
1482 |
> |
LinkedBlockingDeque<Item> p = new LinkedBlockingDeque<>(SIZE); |
1483 |
|
for (int i = 0; i < SIZE; ++i) { |
1484 |
|
assertTrue(q.containsAll(p)); |
1485 |
|
assertFalse(p.containsAll(q)); |
1550 |
|
/** |
1551 |
|
* toArray(incompatible array type) throws ArrayStoreException |
1552 |
|
*/ |
1553 |
< |
public void testToArray1_BadArg() { |
1553 |
> |
@SuppressWarnings("CollectionToArraySafeParameter") |
1554 |
> |
public void testToArray_incompatibleArrayType() { |
1555 |
|
LinkedBlockingDeque<Item> q = populatedDeque(SIZE); |
1556 |
|
try { |
1557 |
|
q.toArray(new String[10]); |
1582 |
|
* iterator of empty collection has no elements |
1583 |
|
*/ |
1584 |
|
public void testEmptyIterator() { |
1585 |
< |
Deque<Item> c = new LinkedBlockingDeque<Item>(); |
1585 |
> |
Deque<Item> c = new LinkedBlockingDeque<>(); |
1586 |
|
assertIteratorExhausted(c.iterator()); |
1587 |
|
assertIteratorExhausted(c.descendingIterator()); |
1588 |
|
} |
1591 |
|
* iterator.remove removes current element |
1592 |
|
*/ |
1593 |
|
public void testIteratorRemove() { |
1594 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(3); |
1594 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(3); |
1595 |
|
q.add(two); |
1596 |
|
q.add(one); |
1597 |
|
q.add(three); |
1610 |
|
* iterator ordering is FIFO |
1611 |
|
*/ |
1612 |
|
public void testIteratorOrdering() { |
1613 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(3); |
1613 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(3); |
1614 |
|
q.add(one); |
1615 |
|
q.add(two); |
1616 |
|
q.add(three); |
1626 |
|
* Modifications do not cause iterators to fail |
1627 |
|
*/ |
1628 |
|
public void testWeaklyConsistentIteration() { |
1629 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(3); |
1629 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(3); |
1630 |
|
q.add(one); |
1631 |
|
q.add(two); |
1632 |
|
q.add(three); |
1660 |
|
* Descending iterator ordering is reverse FIFO |
1661 |
|
*/ |
1662 |
|
public void testDescendingIteratorOrdering() { |
1663 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
1663 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
1664 |
|
for (int iters = 0; iters < 100; ++iters) { |
1665 |
|
mustAdd(q, three); |
1666 |
|
mustAdd(q, two); |
1682 |
|
* descendingIterator.remove removes current element |
1683 |
|
*/ |
1684 |
|
public void testDescendingIteratorRemove() { |
1685 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
1685 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
1686 |
|
for (int iters = 0; iters < 100; ++iters) { |
1687 |
|
mustAdd(q, three); |
1688 |
|
mustAdd(q, two); |
1715 |
|
* offer transfers elements across Executor tasks |
1716 |
|
*/ |
1717 |
|
public void testOfferInExecutor() { |
1718 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(2); |
1718 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(2); |
1719 |
|
q.add(one); |
1720 |
|
q.add(two); |
1721 |
|
final CheckedBarrier threadsStarted = new CheckedBarrier(2); |
1741 |
|
* timed poll retrieves elements across Executor threads |
1742 |
|
*/ |
1743 |
|
public void testPollInExecutor() { |
1744 |
< |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(2); |
1744 |
> |
final LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(2); |
1745 |
|
final CheckedBarrier threadsStarted = new CheckedBarrier(2); |
1746 |
|
final ExecutorService executor = Executors.newFixedThreadPool(2); |
1747 |
|
try (PoolCleaner cleaner = cleaner(executor)) { |
1784 |
|
*/ |
1785 |
|
public void testDrainTo() { |
1786 |
|
LinkedBlockingDeque<Item> q = populatedDeque(SIZE); |
1787 |
< |
ArrayList<Item> l = new ArrayList<Item>(); |
1787 |
> |
ArrayList<Item> l = new ArrayList<>(); |
1788 |
|
q.drainTo(l); |
1789 |
|
mustEqual(0, q.size()); |
1790 |
|
mustEqual(SIZE, l.size()); |
1814 |
|
}}); |
1815 |
|
|
1816 |
|
t.start(); |
1817 |
< |
ArrayList<Item> l = new ArrayList<Item>(); |
1817 |
> |
ArrayList<Item> l = new ArrayList<>(); |
1818 |
|
q.drainTo(l); |
1819 |
|
assertTrue(l.size() >= SIZE); |
1820 |
|
for (int i = 0; i < SIZE; ++i) |
1827 |
|
* drainTo(c, n) empties first min(n, size) elements of queue into c |
1828 |
|
*/ |
1829 |
|
public void testDrainToN() { |
1830 |
< |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<Item>(); |
1830 |
> |
LinkedBlockingDeque<Item> q = new LinkedBlockingDeque<>(); |
1831 |
|
for (int i = 0; i < SIZE + 2; ++i) { |
1832 |
|
for (int j = 0; j < SIZE; j++) |
1833 |
|
mustOffer(q, j); |
1834 |
< |
ArrayList<Item> l = new ArrayList<Item>(); |
1834 |
> |
ArrayList<Item> l = new ArrayList<>(); |
1835 |
|
q.drainTo(l, i); |
1836 |
|
int k = (i < SIZE) ? i : SIZE; |
1837 |
|
mustEqual(k, l.size()); |
1847 |
|
*/ |
1848 |
|
public void testNeverContainsNull() { |
1849 |
|
Deque<?>[] qs = { |
1850 |
< |
new LinkedBlockingDeque<Object>(), |
1850 |
> |
new LinkedBlockingDeque<>(), |
1851 |
|
populatedDeque(2), |
1852 |
|
}; |
1853 |
|
|