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

x33g5p2x  于2022-01-17 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(215)

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

ConcurrentHashMap.contains介绍

[英]Legacy method testing if some key maps into the specified value in this table. This method is identical in functionality to #containsValue, and exists solely to ensure full compatibility with class java.util.Hashtable, which supported this method prior to introduction of the Java Collections framework.
[中]旧方法测试某些键是否映射到此表中的指定值。该方法在功能上与#containsValue相同,其存在只是为了确保与java类完全兼容。util。Hashtable,它在引入Java集合框架之前支持此方法。

代码示例

代码示例来源:origin: wildfly/wildfly

public boolean contains(final Object value) {
  return backingMap.contains(value);
}

代码示例来源:origin: stackoverflow.com

ConcurrentHashMap<String, Integer> myMap = new ConcurrentHashMap<String, Integer>();

// some stuff

if (!myMap.contains("key")) {
 myMap.put("key", 3);
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * Register a new contentType to charSet mapping.
 * @param contentType Content-type to register
 * @param charSet charSet associated with the content-type
 */
public void registerCharsetMapping(String contentType, String charSet) {
 if (knownCharsets.contains(contentType)) {
  log.warn("{} is already registered; re-registering");
 }
 knownCharsets.put(contentType, charSet);
}

代码示例来源:origin: spotbugs/spotbugs

@NoWarning("GC_UNRELATED_TYPES")
public boolean testContainsConcurrentHashMap(Integer i) {
  return concurrentHashMap.contains(i);
}

代码示例来源:origin: spotbugs/spotbugs

@ExpectWarning("GC_UNRELATED_TYPES")
public boolean testContainsConcurrentHashMap(String s) {
  return concurrentHashMap.contains(s);
}

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

/**
 * Block indexing.
 *
 * @param nodeId Node.
 */
@SuppressWarnings("SuspiciousMethodCalls")
private static CountDownLatch blockIndexing(UUID nodeId) {
  assertFalse(BLOCKS.contains(nodeId));
  CountDownLatch idxLatch = new CountDownLatch(1);
  BLOCKS.put(nodeId, new T3<>(new CountDownLatch(1), new AtomicBoolean(), idxLatch));
  return idxLatch;
}

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

/**
 * Block indexing.
 *
 * @param nodeId Node.
 */
@SuppressWarnings("SuspiciousMethodCalls")
private static CountDownLatch blockIndexing(UUID nodeId) {
  assertFalse(BLOCKS.contains(nodeId));
  CountDownLatch idxLatch = new CountDownLatch(1);
  BLOCKS.put(nodeId, new T3<>(new CountDownLatch(1), new AtomicBoolean(), idxLatch));
  return idxLatch;
}

代码示例来源:origin: nutzam/nutz

protected Processor getProcessorByName(NutConfig config,String name) throws Exception {
    if (name.startsWith("ioc:") && name.length() > 4) {
      if (config.getIoc() == null)
        throw new IllegalArgumentException("getProcessorByName " + name + " but no ioc !");
      return config.getIoc().get(Processor.class, name.substring(4).trim());
    }
    else {
      Class<?> klass = null;
      if (name.startsWith("!")) {
        name = name.substring(1);
        if (disabledProcessor.contains(name))
          return null;
        try {
          klass = Lang.loadClass(name);
        }
        catch (Throwable e) {
          log.info("Optional processor class not found, disabled : " + name);
          disabledProcessor.put(name, name);
          return null;
        }
        return (Processor) Mirror.me(klass).born();
      }
      return (Processor) Mirror.me(Lang.loadClass(name)).born();
    }
  }
}

代码示例来源:origin: alibaba/jstorm

if (!topologyIdtoSem.contains(topologyId)) {
  topologyIdtoSem.putIfAbsent(topologyId, new Semaphore(0));

代码示例来源:origin: neoremind/fluent-validator

if (CLASS_2_ANNOTATION_VALIDATOR_MAP.contains(clazz)) {
  return;

代码示例来源:origin: yahoo/elide

/**
 * Returns whether or not a class is already bound.
 * @param cls
 * @return
 */
public boolean hasBinding(Class<?> cls) {
  return bindJsonApiToEntity.contains(cls);
}

代码示例来源:origin: com.blazegraph/bigdata-core

/**
 * Return <code>true</code> if writes have been disabled for the named
 * index.
 * 
 * @param name
 *            The index name.
 *            
 * @return <code>true</code> if writes are disabled for that index.
 */
public boolean isDisabledWrites(final String name) {
  return disabledShards.contains(name);
}

代码示例来源:origin: com.yahoo.elide/elide-core

/**
 * Returns whether or not a class is already bound.
 * @param cls
 * @return
 */
public boolean hasBinding(Class<?> cls) {
  return bindJsonApiToEntity.contains(cls);
}

代码示例来源:origin: sakaiproject/sakai

public boolean contains(String ifaceName) {
  String key = ifaceName != null ? ifaceName : "";
  return components.contains(key);
}

代码示例来源:origin: org.opendaylight.alto.core/alto-northbound-impl

@Override
public String addRoute(String routeName, AltoNorthboundRoute route) {
  if (routes.contains(routeName)) {
    return null;
  }
  routes.put(routeName, route);
  return "/alto/" + routeName;
}

代码示例来源:origin: org.apache.gobblin/gobblin-metadata

/**
 * Register a new contentType to charSet mapping.
 * @param contentType Content-type to register
 * @param charSet charSet associated with the content-type
 */
public void registerCharsetMapping(String contentType, String charSet) {
 if (knownCharsets.contains(contentType)) {
  log.warn("{} is already registered; re-registering");
 }
 knownCharsets.put(contentType, charSet);
}

代码示例来源:origin: com.linkedin.gobblin/gobblin-metadata

/**
 * Register a new contentType to charSet mapping.
 * @param contentType Content-type to register
 * @param charSet charSet associated with the content-type
 */
public void registerCharsetMapping(String contentType, String charSet) {
 if (knownCharsets.contains(contentType)) {
  log.warn("{} is already registered; re-registering");
 }
 knownCharsets.put(contentType, charSet);
}

代码示例来源:origin: com.sleepycat/je

void leave() {
    assert activeThreads.contains(Thread.currentThread());
    activeThreads.remove(Thread.currentThread());
  }
}

代码示例来源:origin: arun-gupta/microservices

@Override
public void unregisterService(String name, String uri) {
  try {
    if (uriToZnodePath.contains(uri)) {
      curatorFramework.delete().forPath(uriToZnodePath.get(uri));
    }
  } catch (Exception ex) {
    throw new RuntimeException("Could not unregister service \"" 
        + name 
        + "\", with URI \"" + uri + "\": " + ex.getLocalizedMessage());
  }
}

代码示例来源:origin: xyz.codemeans.protobuf4j/protobuf4j-core

@SuppressWarnings("unchecked")
public static <T extends GeneratedMessageV3> ProtoMessageCodec<T> getProtoMessageCodec(
  @Nonnull Class<T> cls) {
 Preconditions.checkNotNull(cls);
 if (!protoCodecMap.contains(cls)) {
  ProtoMessageCodec<T> codec = new ProtoMessageCodec<>(cls);
  protoCodecMap.putIfAbsent(cls, codec);
 }
 return (ProtoMessageCodec<T>) protoCodecMap.get(cls);
}

相关文章