Java Queue Usage convertQueueToArray(Queue q)

Here you can find the source of convertQueueToArray(Queue q)

Description

convert Queue To Array

License

Apache License

Declaration

public static <K> List<K> convertQueueToArray(Queue<K> q) 

Method Source Code


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

import java.util.ArrayList;

import java.util.List;

import java.util.PriorityQueue;
import java.util.Queue;

public class Main {
    public static <K> List<K> convertQueueToArray(Queue<K> q) {
        Queue<K> temp = new PriorityQueue<K>(q);
        List<K> list = new ArrayList<K>();
        while (temp.size() > 0)
            list.add(temp.poll());//from w w w . j a v a  2 s .c  om
        return list;
    }
}

Related

  1. addElementsToQueueInSingleThread(int numberOfElements, Queue queue, int element)
  2. addStringArraytoQueue(Queue set, String[] array)
  3. asString(Queue values)
  4. bQToString(Queue bQ)
  5. elementFail(Queue q)
  6. get(Queue queue, int index)
  7. getAllElementsFromQueueAsList(Queue queue)
  8. isListBased(Class type)

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