java.util.ArrayDeque.contains()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(196)

本文整理了Java中java.util.ArrayDeque.contains()方法的一些代码示例,展示了ArrayDeque.contains()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArrayDeque.contains()方法的具体详情如下:
包路径:java.util.ArrayDeque
类名称:ArrayDeque
方法名:contains

ArrayDeque.contains介绍

[英]Returns true if this deque contains the specified element. More formally, returns true if and only if this deque contains at least one element e such that o.equals(e).
[中]如果此数据包含指定的元素,则返回true。更正式地说,当且仅当此deque至少包含一个元素e,使得o.equals(e)时,返回true。

代码示例

代码示例来源:origin: apache/ignite

if (!nodeQueue.contains(node))
  nodeQueue.offer(node);

代码示例来源:origin: apache/ignite

/**
 * @param type Message type.
 * @param customMsg Custom message.
 * @return {@code True} if should not process message.
 */
private boolean skipMessage(int type, @Nullable DiscoveryCustomMessage customMsg) {
  if (type == EVT_DISCOVERY_CUSTOM_EVT) {
    assert customMsg != null && customMsg.id() != null : customMsg;
    if (rcvdCustomMsgs.contains(customMsg.id())) {
      if (log.isDebugEnabled())
        log.debug("Received duplicated custom message, will ignore [msg=" + customMsg + "]");
      return true;
    }
    rcvdCustomMsgs.addLast(customMsg.id());
    while (rcvdCustomMsgs.size() > DISCOVERY_HISTORY_SIZE)
      rcvdCustomMsgs.pollFirst();
  }
  return false;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public boolean contains(Object o) {
  return queue.contains(o);
}

代码示例来源:origin: baidu/brpc-java

@Override
public boolean contains(Object o) {
  return queue.contains(o);
}

代码示例来源:origin: org.zeromq/jeromq

@Override
public boolean contains(Object o)
{
  return frames.contains(o);
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

@Override
public boolean contains(Object o) {
  return queue.contains(o);
}

代码示例来源:origin: org.codelibs/elasticsearch-querybuilders

@Override
public boolean contains(Object o) {
  return queue.contains(o);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public boolean contains(Object o) {
  return queue.contains(o);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

@Override
public boolean contains(Object o) {
  return queue.contains(o);
}

代码示例来源:origin: com.baidu/brpc-java

@Override
public boolean contains(Object o) {
  return queue.contains(o);
}

代码示例来源:origin: arteam/100-Java-Concurrency-questions

@Override
public synchronized boolean contains(Object o) {
  return deque.contains(o);
}

代码示例来源:origin: laizimo/richeditor

public boolean contain(long id){
  return stateAList.contains(id) || stateBList.contains(id);
}

代码示例来源:origin: org.kie.server/kie-server-client

@Override
public String markAsOnline(String url) {
  synchronized (availableEndpoints) {
    String baseUrl = locateUrl(availableEndpoints, url);
    
    if (!availableEndpoints.contains(baseUrl)) {
      availableEndpoints.addLast(baseUrl);
    }
    
    return baseUrl;
  }
}

代码示例来源:origin: io.github.factoryfx/factory

private void loopDetector(FactoryBase<?,?, ?> factory, ArrayDeque<FactoryBase<?, ?, ?>> stack, final long iterationRun){
  if (factory.iterationRun==iterationRun){
    if (stack.contains(factory)){
      throw new IllegalStateException("Factories contains a cycle, circular dependencies are not supported cause it indicates a design flaw.");
    }
  } else {
    stack.push(factory);
    factory.visitChildFactoriesAndViewsFlat(child -> {
      loopDetector(child,stack,iterationRun);
    },iterationRun);
    stack.pop();
  }
}

代码示例来源:origin: pvto/konte-art

private void addLatest(String s)
{
  if (deq.contains(s))
    deq.remove(s);
  deq.addFirst(s);
}

代码示例来源:origin: laizimo/richeditor

public void changeState(long id){
  long temp;
  if(stateAList.contains(id)){
    stateAList.remove(id);
    if(num > 0 && stateBList.size() >= num){
      temp = stateBList.poll();
      stateAList.add(temp);
      if(handler != null)
        handler.handleB2A(temp);
    }
    stateBList.add(id);
    if(handler != null)
      handler.handleA2B(id);
  }else if(stateBList.contains(id)){
    stateBList.remove(id);
    stateAList.add(id);
    if(handler != null)
      handler.handleB2A(id);
  }
}

代码示例来源:origin: freenet/fred

public void executeNoDupes(Runnable job, int prio, String jobName) {
  synchronized(jobs) {
    if(jobs[prio].contains(job)) {
      if(logMINOR)
        Logger.minor(this, "Not queueing job: Job already queued: "+job);
      return;
    }
    if(logMINOR)
      Logger.minor(this, "Queueing "+jobName+" : "+job+" priority "+prio+", executor state: running="+running+" waiting="+waiting);
    jobs[prio].addLast(job);
    jobs.notifyAll();
    if(!running && realExecutor != null) {
      reallyStart();
    }
  }
}

代码示例来源:origin: beworker/magnet

void onBeginInstantiation(String key) {
  if (currentInstantiation != null) {
    instantiations.addFirst(currentInstantiation);
  }
  currentInstantiation = new Instantiation(key);
  if (instantiations.contains(currentInstantiation)) {
    throw createCircularDependencyException();
  }
}

代码示例来源:origin: freenet/fred

public void queueRequest(SendableGet getter, BlockSet blocks) {
  Key[] checkKeys = getter.listKeys();
  short prio = getter.getPriorityClass();
  if(logMINOR) Logger.minor(this, "Queueing transient request "+getter+" priority "+prio+" keys "+checkKeys.length);
  // FIXME check using store.probablyInStore
  ArrayList<Key> finalKeysToCheck = new ArrayList<Key>(checkKeys.length);
  synchronized(this) {
    for(Key key : checkKeys) {
      finalKeysToCheck.add(key);
    }
    QueueItem queueItem = new QueueItem(
        finalKeysToCheck.toArray(new Key[finalKeysToCheck.size()]),
        getter, blocks);
    if(logMINOR && queue[prio].contains(queueItem)) {
      Logger.error(this, "Transient request "+getter+" is already queued!");
      return;
    }
    queue[prio].add(queueItem);
    wakeUp();
  }
}

代码示例来源:origin: org.apache.ignite/ignite-core

/**
 * @param type Message type.
 * @param customMsg Custom message.
 * @return {@code True} if should not process message.
 */
private boolean skipMessage(int type, @Nullable DiscoveryCustomMessage customMsg) {
  if (type == EVT_DISCOVERY_CUSTOM_EVT) {
    assert customMsg != null && customMsg.id() != null : customMsg;
    if (rcvdCustomMsgs.contains(customMsg.id())) {
      if (log.isDebugEnabled())
        log.debug("Received duplicated custom message, will ignore [msg=" + customMsg + "]");
      return true;
    }
    rcvdCustomMsgs.addLast(customMsg.id());
    while (rcvdCustomMsgs.size() > DISCOVERY_HISTORY_SIZE)
      rcvdCustomMsgs.pollFirst();
  }
  return false;
}

相关文章