Java Queue Create toQueue(T[] array)

Here you can find the source of toQueue(T[] array)

Description

Converts an array of T into a Queue of T.

License

Open Source License

Parameter

Parameter Description
T The T element.
array An array of T.

Return

A queue of T.

Declaration

private static <T> Queue<T> toQueue(T[] array) 

Method Source Code

//package com.java2s;

import java.util.LinkedList;

import java.util.Queue;

public class Main {
    /**//from   w  w  w .  j a  v  a2 s  . c o m
     * Gets a queue from a property path.
     * 
     * @param propPath The property path.
     * @return A queue from the property path.
     */
    private static Queue<String> toQueue(String propPath) {
        String[] parts = propPath.split("\\.");
        return toQueue(parts);
    }

    /**
     * Converts an array of T into a Queue of T.
     * 
     * @param <T> The T element.
     * @param array An array of T.
     * @return A queue of T.
     */
    private static <T> Queue<T> toQueue(T[] array) {
        Queue<T> q = new LinkedList<T>();

        for (T a : array) {
            q.add(a);
        }

        return q;
    }
}

Related

  1. getArrayQueue()
  2. getQueue()