Example usage for java.util ArrayDeque pollLast

List of usage examples for java.util ArrayDeque pollLast

Introduction

In this page you can find the example usage for java.util ArrayDeque pollLast.

Prototype

public E pollLast() 

Source Link

Usage

From source file:Main.java

public static void main(String[] args) {

    ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8);

    deque.add(25);/*www.j a v a  2 s .  c  o  m*/
    deque.add(2);
    deque.add(1);
    deque.add(18);

    System.out.println(deque);
    int retval = deque.pollLast();
    System.out.println("Element removed is " + retval);

    System.out.println(deque);
}

From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java

public void testPollLast() {
    Object o1 = new Object();
    Object o2 = new Object();

    ArrayDeque<Object> deque = new ArrayDeque<>();
    assertNull(deque.pollLast());
    assertTrue(deque.isEmpty());/*from  w w w.j a va  2 s. co  m*/

    deque.add(o1);
    assertEquals(o1, deque.pollLast());
    assertTrue(deque.isEmpty());
    assertNull(deque.pollFirst());

    deque.add(o1);
    deque.add(o2);
    assertEquals(o2, deque.pollLast());
    checkDequeSizeAndContent(deque, o1);
    assertEquals(o1, deque.pollLast());
    assertTrue(deque.isEmpty());
    assertNull(deque.pollLast());
}