Java Queue Usage getAllElementsFromQueueAsList(Queue queue)

Here you can find the source of getAllElementsFromQueueAsList(Queue queue)

Description

get All Elements From Queue As List

License

LGPL

Declaration

public static <Type> List<Type> getAllElementsFromQueueAsList(Queue<Type> queue) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

public class Main {
    public static <Type> List<Type> getAllElementsFromQueueAsList(Queue<Type> queue) {
        final int size = queue.size();

        List<Type> result = new ArrayList<>();

        for (int i = 0; i < size; i++) {
            result.add(queue.poll());//w  w w  . ja  v  a 2 s .  c o  m
        }

        return result;
    }
}

Related

  1. asString(Queue values)
  2. bQToString(Queue bQ)
  3. convertQueueToArray(Queue q)
  4. elementFail(Queue q)
  5. get(Queue queue, int index)
  6. isListBased(Class type)
  7. isQueue(final Object value, final boolean acceptNull)
  8. loadBalancingLeftHeavy(List tasks, int size)
  9. offerUntilSuccess(T entry, Queue queue)

  10. HOME | Copyright © www.java2s.com 2016