コード例 #1
0
  /** @throws Exception If failed. */
  public void testPoll() throws Exception {
    ConcurrentLinkedDeque8<Integer> deque = new ConcurrentLinkedDeque8<>();

    deque.add(1);
    deque.add(2);
    deque.add(3);

    assert !deque.isEmpty();

    checkSize(deque, 3);

    // Poll 1.
    assertEquals(Integer.valueOf(1), deque.poll());

    assert !deque.isEmpty();

    checkSize(deque, 2);

    // Poll 2.
    assertEquals(Integer.valueOf(2), deque.poll());

    assert !deque.isEmpty();

    checkSize(deque, 1);

    // Poll 3.
    assertEquals(Integer.valueOf(3), deque.poll());

    assert deque.isEmpty();

    checkSize(deque, 0);
  }
コード例 #2
0
  public void testEmptyDeque() {
    ConcurrentLinkedDeque8<Integer> deque = new ConcurrentLinkedDeque8<>();

    assert deque.poll() == null;
    assert deque.pollFirst() == null;
    assert deque.pollLast() == null;

    assert deque.peek() == null;
    assert deque.peekFirst() == null;
    assert deque.peekLast() == null;

    checkSize(deque, 0);
  }