List of usage examples for java.util ArrayDeque remove
public E remove()
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25);//from w w w . j av a 2 s .c o m deque.add(2); deque.add(1); deque.add(40); // this will remove element at the first(head) postion int retval = deque.remove(); System.out.println("Element removed is: " + retval); System.out.println(deque); }
From source file:name.abhijitsarkar.algorithms.core.Sorter.java
private static int[] gather(ArrayDeque<int[]> stack) { int[] mergedBucket = null; while (!stack.isEmpty()) { mergedBucket = stack.remove(); if (!stack.isEmpty()) { int[] bucket = stack.remove(); mergedBucket = merge(mergedBucket, bucket); stack.add(mergedBucket);// w w w . ja v a 2 s.c o m } } return mergedBucket; }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testRemove() { Object o1 = new Object(); Object o2 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); try {//w w w . j a va 2 s. c o m deque.remove(); fail(); } catch (NoSuchElementException expected) { } deque.add(o1); assertEquals(o1, deque.remove()); assertTrue(deque.isEmpty()); deque.add(o1); deque.add(o2); assertEquals(o1, deque.remove()); checkDequeSizeAndContent(deque, o2); assertEquals(o2, deque.removeFirst()); assertTrue(deque.isEmpty()); try { deque.remove(); fail(); } catch (NoSuchElementException expected) { } }