Ejemplo n.º 1
0
 /**
  * Creates an {@code ArrayDeque} containing the elements of the specified iterable, in the order
  * they are returned by the iterable's iterator.
  *
  * @since 12.0
  */
 public static <E> ArrayDeque<E> newArrayDeque(Iterable<? extends E> elements) {
   if (elements instanceof Collection) {
     return new ArrayDeque<E>(Collections2.cast(elements));
   }
   ArrayDeque<E> deque = new ArrayDeque<E>();
   Iterables.addAll(deque, elements);
   return deque;
 }
Ejemplo n.º 2
0
 /**
  * Creates a {@code LinkedBlockingQueue} with a capacity of {@link Integer#MAX_VALUE}, containing
  * the elements of the specified iterable, in the order they are returned by the iterable's
  * iterator.
  *
  * @param elements the elements that the queue should contain, in order
  * @return a new {@code LinkedBlockingQueue} containing those elements
  */
 public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(Iterable<? extends E> elements) {
   if (elements instanceof Collection) {
     return new LinkedBlockingQueue<E>(Collections2.cast(elements));
   }
   LinkedBlockingQueue<E> queue = new LinkedBlockingQueue<E>();
   Iterables.addAll(queue, elements);
   return queue;
 }
Ejemplo n.º 3
0
 /**
  * Creates a {@code PriorityQueue} containing the given elements.
  *
  * <p><b>Note:</b> If the specified iterable is a {@code SortedSet} or a {@code PriorityQueue},
  * this priority queue will be ordered according to the same ordering.
  *
  * @since 11.0 (requires that {@code E} be {@code Comparable} since 15.0).
  */
 public static <E extends Comparable> PriorityQueue<E> newPriorityQueue(
     Iterable<? extends E> elements) {
   if (elements instanceof Collection) {
     return new PriorityQueue<E>(Collections2.cast(elements));
   }
   PriorityQueue<E> queue = new PriorityQueue<E>();
   Iterables.addAll(queue, elements);
   return queue;
 }