Example usage for java.util ArrayDeque offerFirst

List of usage examples for java.util ArrayDeque offerFirst

Introduction

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

Prototype

public boolean offerFirst(E e) 

Source Link

Document

Inserts the specified element at the front of this deque.

Usage

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

public void testOfferFirst() {
    Object o1 = new Object();
    Object o2 = new Object();
    Object o3 = new Object();

    ArrayDeque<Object> deque = new ArrayDeque<>();
    assertTrue(deque.offerFirst(o1));
    checkDequeSizeAndContent(deque, o1);
    assertTrue(deque.offerFirst(o2));/*  w  w  w  .j ava2 s .  c  o  m*/
    checkDequeSizeAndContent(deque, o2, o1);
    assertTrue(deque.offerFirst(o3));
    checkDequeSizeAndContent(deque, o3, o2, o1);

    try {
        deque.offerFirst(null);
        fail();
    } catch (NullPointerException expected) {
    }
}