Example usage for java.util Queue toArray

List of usage examples for java.util Queue toArray

Introduction

In this page you can find the example usage for java.util Queue toArray.

Prototype

<T> T[] toArray(T[] a);

Source Link

Document

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

Usage

From source file:com.android.pwdhashandroid.pwdhash.PasswordHasher.java

private char[] rotate(char[] arr, int amount) {
    //      Log.d(tag, amount + "x:\t");

    Queue<Character> q = CreateQueue(arr);

    while (amount-- != 0) {
        q.add(q.remove());//from  ww  w  .  j  a  va 2  s. c om
        Log.d(tag, q.toString());
    }

    Character[] chars = (Character[]) q.toArray(new Character[0]);
    return CharacterToCharArray(chars);

    //      return new char[10]; 

    //      CSQueue q = new CSQueue(arr);
    //      while (amount-- != 0) {
    //         q.put(q.get());
    //         Log.d(tag, new String(q.toArray()));
    //      }
    //
    //      return q.toArray();
}

From source file:org.apache.synapse.endpoints.EndpointView.java

private int getTotal(Queue<Integer> queue, int count) {
    int sum = 0;/*  ww w. ja v  a  2s.c o  m*/
    Integer[] array = queue.toArray(new Integer[queue.size()]);

    if (count > array.length) {
        for (int i = 0; i < array.length; i++) {
            sum += array[i];
        }
    } else {
        for (int i = 0; i < count; i++) {
            sum += array[array.length - 1 - i];
        }
    }
    return sum;
}

From source file:org.eclipse.scada.da.utils.daemon.DaemonStarter.java

public static void main(final String[] args) throws Exception {
    if (args.length == 0) {
        throw new RuntimeException("syntax: DaemonStarter <daemon class name>");
    }//from  ww  w .  j  a  v a  2  s .  com

    final Queue<String> argList = new LinkedList<String>();
    argList.addAll(Arrays.asList(args));

    new DaemonStarter(Class.forName(argList.poll()), argList.toArray(new String[0]));

    while (true) {
        Thread.sleep(1000);
    }
}