Example usage for java.util PriorityQueue PriorityQueue

List of usage examples for java.util PriorityQueue PriorityQueue

Introduction

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

Prototype

public PriorityQueue(SortedSet<? extends E> c) 

Source Link

Document

Creates a PriorityQueue containing the elements in the specified sorted set.

Usage

From source file:Main.java

public static <E> PriorityQueue<E> getPriorityQueue(SortedSet<? extends E> set) {
    return new PriorityQueue<E>(set);
}

From source file:Main.java

public static <E> PriorityQueue<E> newPriorityQueue(final Collection<? extends E> c) {
    return new PriorityQueue<E>(c);
}

From source file:Main.java

public static <E> PriorityQueue<E> createPriorityQueue(PriorityQueue<? extends E> queue) {
    if (queue == null) {
        return null;
    }/* w ww .  j  av  a  2s  .co m*/

    return new PriorityQueue<E>(queue);
}

From source file:Main.java

public static <E> PriorityQueue<E> newPriorityQueue(final int initialCapacity) {
    return new PriorityQueue<E>(initialCapacity);
}

From source file:Main.java

public static <E> PriorityQueue<E> createPriorityQueue(SortedSet<? extends E> set) {
    if (set == null) {
        return null;
    }/*from  w w  w.  j a  v  a 2  s .  com*/

    return new PriorityQueue<E>(set);
}

From source file:Main.java

public static <E> PriorityQueue<E> newPriorityQueue(final PriorityQueue<? extends E> c) {
    return new PriorityQueue<E>(c);
}

From source file:Main.java

public static <E> PriorityQueue<E> newPriorityQueue(final SortedSet<? extends E> c) {
    return new PriorityQueue<E>(c);
}

From source file:com.mellanox.jxio.tests.benchmarks.DataPathTestServer.java

public DataPathTestServer(String args[]) {
    super(args);//from  w w  w . j  a  v  a  2 s  . co m
    listen_eqh = new EventQueueHandler(null);
    tsc = new TestServerCallbacks();
    listener = new ServerPortal(listen_eqh, uri, tsc, this);
    SPWorkers = new PriorityQueue<ServerPortalWorker>(num_of_threads);
    //adding 64 to num_of_buffers_per_thread due to ACCELLIO demand
    for (int i = 0; i < num_of_threads; i++) {
        SPWorkers.add(new ServerPortalWorker(i, inMsg_size, outMsg_size, listener.getUriForServer(),
                burst_size + 64));
    }
}

From source file:org.accelio.jxio.tests.benchmarks.DataPathTestServer.java

public DataPathTestServer(String args[]) {
    super(args);//from  w ww . ja  va 2s  .  c  o  m
    listen_eqh = new EventQueueHandler(null);
    tsc = new TestServerCallbacks();
    listener = new ServerPortal(listen_eqh, uri, tsc, this);
    SPWorkers = new PriorityQueue<ServerPortalWorker>(num_of_threads);
    //adding 64 to num_of_buffers_per_thread due to ACCELLIO demand
    for (int i = 0; i < num_of_threads; i++) {
        SPWorkers.add(new ServerPortalWorker(i, inMsg_size, outMsg_size, listener.getUriForServer(),
                burst_size + 64, tsc));
    }
}

From source file:com.parse.PushHistory.java

/**
 * Creates a push history object from a JSON object that looks like this:
 * /*  w  w  w.  j  a  va  2 s  . co m*/
 * {
 *    "seen": {
 *        "push_id_1": "2013-11-01T22:01:00.000Z",
 *        "push_id_2": "2013-11-01T22:01:01.000Z",
 *        "push_id_3": "2013-11-01T22:01:02.000Z"
 *    },
 *    "lastTime": "2013-11-01T22:01:02.000Z"
 * }
 * 
 * The "history" entries correspond to entries in the "entries" queue.
 * The "lastTime" entry corresponds to the "lastTime" field.
 */
public PushHistory(int maxHistoryLength, JSONObject json) {
    this.maxHistoryLength = maxHistoryLength;
    this.entries = new PriorityQueue<Entry>(maxHistoryLength + 1);
    this.pushIds = new HashSet<String>(maxHistoryLength + 1);
    this.lastTime = null;

    if (json != null) {
        JSONObject jsonHistory = json.optJSONObject("seen");
        if (jsonHistory != null) {
            Iterator<String> it = jsonHistory.keys();
            while (it.hasNext()) {
                String pushId = (String) it.next();
                String timestamp = jsonHistory.optString(pushId, null);

                if (pushId != null && timestamp != null) {
                    tryInsertPush(pushId, timestamp);
                }
            }
        }
        setLastReceivedTimestamp(json.optString("lastTime", null));
    }
}