本文整理了Java中java.util.IdentityHashMap.containsKey()
方法的一些代码示例,展示了IdentityHashMap.containsKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IdentityHashMap.containsKey()
方法的具体详情如下:
包路径:java.util.IdentityHashMap
类名称:IdentityHashMap
方法名:containsKey
[英]Tests whether the specified object reference is a key in this identity hash map.
[中]测试指定的对象引用是否是此标识哈希映射中的键。
代码示例来源:origin: SonarSource/sonarqube
void match(RAW raw, BASE base) {
if (!rawToBase.containsKey(raw)) {
rawToBase.put(raw, base);
baseToRaw.put(base, raw);
}
}
代码示例来源:origin: apache/incubator-dubbo
private static JavaBeanDescriptor createDescriptorIfAbsent(Object obj, JavaBeanAccessor accessor, IdentityHashMap<Object, JavaBeanDescriptor> cache) {
if (cache.containsKey(obj)) {
return cache.get(obj);
} else if (obj instanceof JavaBeanDescriptor) {
return (JavaBeanDescriptor) obj;
} else {
JavaBeanDescriptor result = createDescriptorForSerialize(obj.getClass());
cache.put(obj, result);
serializeInternal(result, obj, accessor, cache);
return result;
}
}
代码示例来源:origin: apache/incubator-dubbo
private static JavaBeanDescriptor createDescriptorIfAbsent(Object obj, JavaBeanAccessor accessor, IdentityHashMap<Object, JavaBeanDescriptor> cache) {
if (cache.containsKey(obj)) {
return cache.get(obj);
} else if (obj instanceof JavaBeanDescriptor) {
return (JavaBeanDescriptor) obj;
} else {
JavaBeanDescriptor result = createDescriptorForSerialize(obj.getClass());
cache.put(obj, result);
serializeInternal(result, obj, accessor, cache);
return result;
}
}
代码示例来源:origin: protostuff/protostuff
/**
* If you are sure that you are only using a single implementation of your interface/abstract class, then it
* makes sense to map it directly to its impl class to avoid writing the type.
* <p>
* Note that the type is always written when your field is {@link java.lang.Object}.
* <p>
* Pojo ids start at 1.
*/
@Override
public <T> Registry mapPojo(Class<? super T> baseClass, Class<T> implClass)
{
if (strategy.pojoMapping.containsKey(baseClass))
throw new IllegalArgumentException("Duplicate registration for: " + baseClass);
BaseHS<?> wrapper = strategy.pojoMapping.get(implClass);
if (wrapper == null)
throw new IllegalArgumentException("Must register the impl class first. " + implClass);
strategy.pojoMapping.put(baseClass, wrapper);
return this;
}
代码示例来源:origin: org.apache.lucene/lucene-core
/**
* Prunes the blockedQueue by removing all DWPT that are associated with the given flush queue.
*/
private void pruneBlockedQueue(final DocumentsWriterDeleteQueue flushingQueue) {
Iterator<BlockedFlush> iterator = blockedFlushes.iterator();
while (iterator.hasNext()) {
BlockedFlush blockedFlush = iterator.next();
if (blockedFlush.dwpt.deleteQueue == flushingQueue) {
iterator.remove();
assert !flushingWriters.containsKey(blockedFlush.dwpt) : "DWPT is already flushing";
// Record the flushing DWPT to reduce flushBytes in doAfterFlush
flushingWriters.put(blockedFlush.dwpt, Long.valueOf(blockedFlush.bytes));
// don't decr pending here - it's already done when DWPT is blocked
flushQueue.add(blockedFlush.dwpt);
}
}
}
代码示例来源:origin: protostuff/protostuff
/**
* Pojo ids start at 1.
*/
@Override
public <T> Registry registerPojo(Class<T> clazz, int id)
{
if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers()))
throw new IllegalArgumentException("Not a concrete class: " + clazz);
if (id < 1)
throw new IllegalArgumentException("pojo ids start at 1.");
if (id >= strategy.pojos.size())
grow(strategy.pojos, id + 1);
else if (strategy.pojos.get(id) != null)
{
throw new IllegalArgumentException("Duplicate id registration: " + id +
" (" + clazz.getName() + ")");
}
if (strategy.pojoMapping.containsKey(clazz))
throw new IllegalArgumentException("Duplicate registration for: " + clazz);
BaseHS<T> wrapper = new Lazy<T>(id, clazz, strategy);
strategy.pojos.set(id, wrapper);
strategy.pojoMapping.put(clazz, wrapper);
return this;
}
代码示例来源:origin: apache/hive
private static void throwRangesError(DiskRangeList ranges, long offset, long end) {
seen.put(ranges, true);
StringBuilder errors = new StringBuilder();
while (ranges.prev != null) {
if (seen.containsKey(ranges.prev)) {
errors.append("loop: [").append(ranges).append(
"].prev = [").append(ranges.prev).append("]; ");
seen.put(ranges, true);
seen.put(ranges, true);
StringBuilder sb = new StringBuilder("Incorrect ranges detected while looking for ");
if (offset == end) {
"].next.prev = [").append(ranges.next.prev).append("]; ");
if (seen.containsKey(ranges.next)) {
errors.append("loop: [").append(ranges).append(
"].next = [").append(ranges.next).append("]; ");
代码示例来源:origin: apache/drill
private static void throwRangesError(DiskRangeList ranges, long offset, long end) {
seen.put(ranges, true);
StringBuilder errors = new StringBuilder();
while (ranges.prev != null) {
if (seen.containsKey(ranges.prev)) {
errors.append("loop: [").append(ranges).append(
"].prev = [").append(ranges.prev).append("]; ");
seen.put(ranges, true);
seen.put(ranges, true);
StringBuilder sb = new StringBuilder("Incorrect ranges detected while looking for ");
if (offset == end) {
"].next.prev = [").append(ranges.next.prev).append("]; ");
if (seen.containsKey(ranges.next)) {
errors.append("loop: [").append(ranges).append(
"].next = [").append(ranges.next).append("]; ");
代码示例来源:origin: apache/hive
@Override
public TezSessionState reopen(TezSessionState session) throws Exception {
WmTezSession wmTezSession = ensureOwnedSession(session);
HiveConf sessionConf = wmTezSession.getConf();
if (sessionConf == null) {
// TODO: can this ever happen?
LOG.warn("Session configuration is null for " + wmTezSession);
sessionConf = new HiveConf(conf, WorkloadManager.class);
}
SettableFuture<WmTezSession> future = SettableFuture.create();
currentLock.lock();
try {
if (current.toReopen.containsKey(wmTezSession)) {
throw new AssertionError("The session is being reopened more than once " + session);
}
current.toReopen.put(wmTezSession, future);
notifyWmThreadUnderLock();
} finally {
currentLock.unlock();
}
return future.get();
}
代码示例来源:origin: apache/incubator-dubbo
private static Object instantiateForDeserialize(JavaBeanDescriptor beanDescriptor, ClassLoader loader, IdentityHashMap<JavaBeanDescriptor, Object> cache) {
if (cache.containsKey(beanDescriptor)) {
return cache.get(beanDescriptor);
cache.put(beanDescriptor, result);
} else {
try {
Class<?> cl = name2Class(loader, beanDescriptor.getClassName());
result = instantiate(cl);
cache.put(beanDescriptor, result);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e.getMessage(), e);
代码示例来源:origin: apache/incubator-dubbo
private static Object instantiateForDeserialize(JavaBeanDescriptor beanDescriptor, ClassLoader loader, IdentityHashMap<JavaBeanDescriptor, Object> cache) {
if (cache.containsKey(beanDescriptor)) {
return cache.get(beanDescriptor);
cache.put(beanDescriptor, result);
} else {
try {
Class<?> cl = name2Class(loader, beanDescriptor.getClassName());
result = instantiate(cl);
cache.put(beanDescriptor, result);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e.getMessage(), e);
代码示例来源:origin: protostuff/protostuff
/**
* Pojo ids start at 1.
*/
@Override
public <T> Registry registerPojo(Schema<T> schema, Pipe.Schema<T> pipeSchema,
int id)
{
if (id >= strategy.pojos.size())
grow(strategy.pojos, id + 1);
else if (strategy.pojos.get(id) != null)
{
throw new IllegalArgumentException("Duplicate id registration: " + id +
" (" + schema.typeClass().getName() + ")");
}
if (strategy.pojoMapping.containsKey(schema.typeClass()))
throw new IllegalArgumentException("Duplicate registration for: " + schema.typeClass());
Registered<T> wrapper = new Registered<T>(id, schema, pipeSchema, strategy);
strategy.pojos.set(id, wrapper);
strategy.pojoMapping.put(schema.typeClass(), wrapper);
return this;
}
代码示例来源:origin: oldmanpushcart/greys-anatomy
long result = getShallowSize(target);
final IdentityHashMap<Object, Void> references = new IdentityHashMap<Object, Void>();
references.put(target, null);
final ArrayDeque<Object> unprocessed = new ArrayDeque<Object>();
unprocessed.addFirst(target);
continue;
if (references.containsKey(elem)) {
continue;
references.put(elem, null);
result += getShallowSize(elem);
continue;
if (references.containsKey(value)) {
continue;
references.put(value, null);
result += getShallowSize(value);
} catch (IllegalArgumentException e) {
代码示例来源:origin: apache/kylin
/**
* replace filter on timestamp column to null, so that two tuple filter trees can
* be compared regardless of the filter condition on timestamp column (In top level where conditions concatenated by ANDs)
* @param filter
* @return
*/
@Override
public TupleFilter onSerialize(TupleFilter filter) {
if (filter == null)
return null;
//we just need reference equal
if (root == filter) {
isInTopLevelANDs.put(filter, true);
}
if (isInTopLevelANDs.containsKey(filter)) {
classifyChildrenByMarking(filter);
if (filter instanceof CompareTupleFilter) {
TblColRef c = ((CompareTupleFilter) filter).getColumn();
if (c != null && c.equals(tsColumn)) {
return null;
}
}
}
return filter;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
if( clone != null || index.containsKey(object) ) {
if( log.isLoggable(Level.FINER) ) {
log.finer("cloned:" + object.getClass() + "@" + System.identityHashCode(object)
index.put(object, result);
index.put(object, clone);
index.put(object, clone);
} else {
throw new IllegalArgumentException("Object is not cloneable, type:" + type);
代码示例来源:origin: org.jsoup/jsoup
/**
* Find elements matching selector.
*
* @param query CSS selector
* @param roots root elements to descend into
* @return matching elements, empty if none
*/
public static Elements select(String query, Iterable<Element> roots) {
Validate.notEmpty(query);
Validate.notNull(roots);
Evaluator evaluator = QueryParser.parse(query);
ArrayList<Element> elements = new ArrayList<>();
IdentityHashMap<Element, Boolean> seenElements = new IdentityHashMap<>();
// dedupe elements by identity, not equality
for (Element root : roots) {
final Elements found = select(evaluator, root);
for (Element el : found) {
if (!seenElements.containsKey(el)) {
elements.add(el);
seenElements.put(el, Boolean.TRUE);
}
}
}
return new Elements(elements);
}
代码示例来源:origin: stanfordnlp/CoreNLP
if (fileLocks.containsKey(f)) {
FileSemaphore sem = fileLocks.get(f);
if (sem.isActive()) {
fileLocks.put(f, sem);
代码示例来源:origin: com.google.inject/guice
if (initializablesCache.containsKey(instance)) {
@SuppressWarnings("unchecked") // Map from T to InjectableReference<T>
Initializable<T> cached = (Initializable<T>) initializablesCache.get(instance);
source,
cycleDetectingLockFactory.create(instance.getClass()));
initializablesCache.put(instance, injectableReference);
pendingInjections.add(injectableReference);
return injectableReference;
代码示例来源:origin: org.codehaus.groovy/groovy
public void visitInstanceofNot(BinaryExpression be) {
final BlockStatement currentBlock = typeCheckingContext.enclosingBlocks.getFirst();
assert currentBlock != null;
if (typeCheckingContext.blockStatements2Types.containsKey(currentBlock)) {
// another instanceOf_not was before, no need store vars
} else {
// saving type of variables to restoring them after returning from block
Map<VariableExpression, List<ClassNode>> oldTracker = pushAssignmentTracking();
getTypeCheckingContext().pushTemporaryTypeInfo();
typeCheckingContext.blockStatements2Types.put(currentBlock, oldTracker);
}
pushInstanceOfTypeInfo(be.getLeftExpression(), be.getRightExpression());
}
代码示例来源:origin: apache/avro
if (seenObjects.containsKey(datum)) {
buffer.append(TOSTRING_CIRCULAR_REFERENCE_ERROR_TEXT);
return;
seenObjects.put(datum, datum);
buffer.append("{");
int count = 0;
seenObjects.remove(datum);
} else if (isArray(datum)) {
if (seenObjects.containsKey(datum)) {
buffer.append(TOSTRING_CIRCULAR_REFERENCE_ERROR_TEXT);
return;
seenObjects.remove(datum);
} else if (isMap(datum)) {
if (seenObjects.containsKey(datum)) {
buffer.append(TOSTRING_CIRCULAR_REFERENCE_ERROR_TEXT);
return;
buffer.append("\"");
} else if (datum instanceof GenericData) {
if (seenObjects.containsKey(datum)) {
buffer.append(TOSTRING_CIRCULAR_REFERENCE_ERROR_TEXT);
return;
内容来源于网络,如有侵权,请联系作者删除!