Example usage for java.util.concurrent BlockingQueue contains

List of usage examples for java.util.concurrent BlockingQueue contains

Introduction

In this page you can find the example usage for java.util.concurrent BlockingQueue contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this queue contains the specified element.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int capacity = 10;
    BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity);

    for (int i = 0; i < 10; i++) {
        queue.add(i);//from w  w w. j av  a 2  s  .  c  om
    }

    System.out.println(queue.contains(0));
}

From source file:org.geppetto.simulation.manager.ExperimentRunManager.java

/**
 * @param user/*from   w  ww. ja v  a 2 s. co  m*/
 * @param experiment
 * @throws GeppettoExecutionException
 */
public void cancelExperimentRun(IUser user, IExperiment experiment) throws GeppettoExecutionException {
    BlockingQueue<IExperiment> queuedExperiments = getQueuedExperiments().get(user);
    if (queuedExperiments != null) {
        if (queuedExperiments.contains(experiment)) {
            getQueuedExperiments().get(user).remove(experiment);
        } else {
            throw new GeppettoExecutionException("The experiment " + experiment.getId() + " is not queued.");
        }
    } else {
        throw new GeppettoExecutionException("The user " + user.getName() + " has no queued experiments.");
    }

}