List of usage examples for java.util ArrayDeque ArrayDeque
public ArrayDeque(Collection<? extends E> c)
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25);//from www . j a v a 2s. c om deque.add(2); deque.add(1); deque.add(18); int retval = deque.peekFirst(); System.out.println("Retrieved Element is " + retval); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(5); deque.add(1);/*from w w w. j av a2s .c o m*/ deque.add(2); deque.add(1); deque.add(2); deque.add(3); deque.add(4); deque.add(5); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25);/*from ww w .ja va2 s .co m*/ deque.add(2); deque.add(1); deque.add(18); // this will insert 40 at the end deque.offerLast(40); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(3);//w ww .j av a2 s.c o m deque.add(1); deque.add(25); deque.add(1); // this will remove first occurrence of element 1 deque.removeFirstOccurrence(1); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25);/*from w ww. j a v a 2s . c om*/ deque.add(2); deque.add(35); // adding elements using push() method deque.push(10); deque.push(3); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { Deque<Integer> deque = new ArrayDeque<Integer>(5); deque.add(25);/*from w ww . j a v a 2 s . co m*/ deque.add(30); deque.add(35); deque.addFirst(10); deque.addFirst(15); deque.addFirst(20); deque.add(45); deque.add(40); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { Deque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(15);/* w ww. ja v a 2 s.c o m*/ deque.add(30); deque.add(25); deque.add(40); System.out.println(deque); // this will remove element at last position int retval = deque.removeLast(); System.out.println("Element removed is: " + retval); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(3);/*from ww w . jav a 2s . c om*/ deque.add(2); deque.add(25); deque.add(40); // this will remove element at the first(head) postion int retval = deque.removeFirst(); System.out.println("Element removed is: " + retval); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25);// w ww .ja va 2 s.c o m deque.add(2); deque.add(1); deque.add(18); // this will retrieve head of the queue int retval = deque.peek(); System.out.println("Retrieved Element is " + retval); System.out.println(deque); }
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 . jav a 2 s .com deque.add(2); deque.add(1); deque.add(18); System.out.println(deque); // it will retrive element at first(head) position int retval = deque.element(); System.out.println("Retrieved Element is = " + retval); }