List of usage examples for java.util ArrayDeque add
public boolean add(E e)
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(3); deque.add(18);/* w ww. j a va 2 s. c o m*/ deque.add(25); deque.add(18); System.out.println(deque); }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(); deque.add(3); deque.add(18);/* w ww . ja va2 s .c o m*/ deque.add(25); deque.add(18); 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); deque.add(4);/*from w ww. j ava 2 s . c o m*/ deque.add(25); deque.add(1); for (Iterator itr = deque.iterator(); itr.hasNext();) { System.out.println(itr.next()); } }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25); deque.add(2);// ww w. j av a2 s . c o m 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); deque.add(2);/*w ww. j a va2s . c om*/ 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); deque.add(2);/* w w w. jav a 2 s . co m*/ 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); deque.add(1);/*from w ww . ja v a 2 s. c om*/ 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); deque.add(2);/*from w ww . ja v a2s. c o m*/ 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) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(3); deque.add(2);/* ww w . ja va 2 s .c o m*/ 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); deque.add(2);/* ww w.j av a 2 s . c om*/ 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); }