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) { Deque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(1);//from www . j a v a 2s .com deque.add(2); deque.add(3); deque.add(4); 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(3);/* w w w.j av a 2s . c om*/ deque.add(4); 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) { Deque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(1);// w ww .j ava 2 s.c o m deque.add(2); deque.add(3); deque.add(4); for (Iterator itr = deque.iterator(); itr.hasNext();) { System.out.println(itr.next()); } for (Iterator descItr = deque.descendingIterator(); descItr.hasNext();) { System.out.println(descItr.next()); } }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(1);//from www . ja v a2s .c o m deque.add(2); deque.add(10); deque.add(18); System.out.println(deque); // deque contains element 10 boolean retval = deque.contains(10); if (retval == true) { System.out.println("element 10 is contained in the deque"); } else { System.out.println("element 10 is not contained in the deque"); } // deque does not contain element 25 boolean retval2 = deque.contains(25); if (retval2 == true) { System.out.println("element 25 is contained in the deque"); } else { System.out.println("element 25 is not contained in the deque"); } }
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(3);/*w w w .j a v a2 s. c om*/ deque.add(4); deque.add(25); deque.add(1); //iterator() is used to print all the elements //next() returns the next element on each iteration System.out.println("printing elements using iterator:"); for (Iterator itr = deque.iterator(); itr.hasNext();) { System.out.println(itr.next()); } //descendingIterator() is used to print the elements in reverse order //next() returns the next element on each iteration System.out.println("printing elements in reverse order:"); for (Iterator descItr = deque.descendingIterator(); descItr.hasNext();) { System.out.println(descItr.next()); } }
From source file:Main.java
public static void main(String args[]) { Deque<Integer> deque = new ArrayDeque<Integer>(7); deque.add(1);/* w w w. j a va2 s. c om*/ deque.add(2); deque.add(3); deque.add(4); deque.add(5); // get queue from the deque Queue<Integer> nq = Collections.asLifoQueue(deque); System.out.println("View of the queue is: " + nq); }
From source file:Main.java
public static void main(String[] args) { Collection<Integer> col = new ArrayList<Integer>(); col.add(0);//from w ww .j a v a2 s .c o m ArrayDeque<Integer> deque = new ArrayDeque<Integer>(col); deque.add(3); deque.add(18); deque.add(25); deque.add(18); System.out.println(deque); }
From source file:Main.java
/** * Creates a {@link java.util.Queue} of the given size using Glide's preferred implementation. *//*from w w w.j a v a 2s . c om*/ public static <T> Queue<T> createQueue(int size) { return new ArrayDeque<>(size); }
From source file:Main.java
public static <E> ArrayDeque<E> getArrayQueue(Collection<? extends E> collection) { return new ArrayDeque<E>(collection); }
From source file:Main.java
public static <E> ArrayDeque<E> getArrayDeque(Collection<? extends E> collection) { return new ArrayDeque<E>(collection); }