本文整理了Java中java.util.IdentityHashMap.get()
方法的一些代码示例,展示了IdentityHashMap.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IdentityHashMap.get()
方法的具体详情如下:
包路径:java.util.IdentityHashMap
类名称:IdentityHashMap
方法名:get
[英]Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
More formally, if this map contains a mapping from a key k to a value v such that (key == k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)
A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The #containsKey operation may be used to distinguish these two cases.
[中]返回指定键映射到的值,如果此映射不包含该键的映射,则返回null。
更正式地说,如果这个映射包含从键k到值v的映射,使得(键==k),那么这个方法返回v;否则返回null。(最多可以有一个这样的映射。)
返回值null不一定表示映射不包含键的映射;映射也可能显式地将密钥映射为null。#containsKey操作可用于区分这两种情况。
代码示例来源: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: apache/incubator-druid
private WritableMemory getMemory(ByteBuffer buffer)
{
WritableMemory mem = memCache.get(buffer);
if (mem == null) {
mem = WritableMemory.wrap(buffer, ByteOrder.LITTLE_ENDIAN);
memCache.put(buffer, mem);
}
return mem;
}
代码示例来源:origin: spotbugs/spotbugs
private void addHandler(InstructionHandle handle, CodeExceptionGen exceptionHandler) {
List<CodeExceptionGen> handlerList = codeToHandlerMap.get(handle);
if (handlerList == null) {
handlerList = new LinkedList<>();
codeToHandlerMap.put(handle, handlerList);
}
handlerList.add(exceptionHandler);
}
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
public void addIncoming(Vertex tov, Edge e) {
List<Edge> toIncoming = incoming.get(tov);
if (toIncoming == null) {
toIncoming = new ArrayList<Edge>(INITIAL_EDGELIST_CAPACITY);
incoming.put(tov, toIncoming);
}
if (!toIncoming.contains(e))
toIncoming.add(e);
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
public void addOutgoing(Vertex fromv, Edge e) {
List<Edge> fromOutgoing = outgoing.get(fromv);
if (fromOutgoing == null) {
fromOutgoing = new ArrayList<Edge>(INITIAL_EDGELIST_CAPACITY);
outgoing.put(fromv, fromOutgoing);
}
if (!fromOutgoing.contains(e))
fromOutgoing.add(e);
}
代码示例来源:origin: apache/incubator-dubbo
/**
* If the object has already been written, just write its ref.
*
* @return true if we're writing a ref.
*/
@Override
public boolean addRef(Object object)
throws IOException {
if (_refs == null)
_refs = new IdentityHashMap();
Integer ref = (Integer) _refs.get(object);
if (ref != null) {
int value = ref.intValue();
writeRef(value);
return true;
} else {
_refs.put(object, new Integer(_refs.size()));
return false;
}
}
代码示例来源:origin: apache/hive
void addUpdateError(WmTezSession wmTezSession, int endpointVersion) {
currentLock.lock();
try {
Integer existing = current.updateErrors.get(wmTezSession);
// Only store the latest error, if there are multiple.
if (existing != null && existing >= endpointVersion) return;
current.updateErrors.put(wmTezSession, endpointVersion);
notifyWmThreadUnderLock();
} finally {
currentLock.unlock();
}
}
代码示例来源:origin: wildfly/wildfly
private static Throwable injectDestination(Throwable t, URI destination) {
StackTraceElement[] stackTrace = new StackTraceElement[5];
System.arraycopy(t.getStackTrace(), 0, stackTrace, 1, 4);
stackTrace[0] = new StackTraceElement("", "..use of destination...", destination.toString(), -1);
t.setStackTrace(stackTrace);
IdentityHashMap<Throwable, Throwable> encountered = new IdentityHashMap<>(3);
encountered.put(t, t);
Throwable cause = t.getCause();
while (cause != null && encountered.get(cause) == null) {
encountered.put(cause, cause);
cause.setStackTrace(Arrays.copyOfRange(cause.getStackTrace(), 0, 5));
cause = cause.getCause();
}
return t;
}
代码示例来源: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: apache/geode
private int canonalize(Object object) throws IOException {
Integer id = writtenObjects.get(object);
if (id != null) {
return id.intValue();
}
String toString = object.toString();
id = writtenStrings.get(toString);
if (id != null) {
return id.intValue();
}
id = Integer.valueOf(nextInt++);
outputStream.write(STRING_RECORD);
outputStream.writeUTF(toString);
writtenObjects.put(object, id);
writtenStrings.put(toString, id);
return id.intValue();
}
代码示例来源:origin: spotbugs/spotbugs
/**
* Get the block in the result CFG corresponding to the given subroutine
* block.
*
* @param subBlock
* the subroutine block
* @return the result CFG block
*/
public BasicBlock getBlock(BasicBlock subBlock) {
BasicBlock resultBlock = blockMap.get(subBlock);
if (resultBlock == null) {
resultBlock = result.allocate();
blockMap.put(subBlock, resultBlock);
workList.add(subBlock);
}
return resultBlock;
}
代码示例来源:origin: immutables/immutables
@Override
public AdapterDecider apply(ValueAttribute input) {
AdapterDecider d = cache.get(input);
if (d == null) {
d = new AdapterDecider(input, enums());
cache.put(input, d);
}
return d;
}
};
代码示例来源:origin: MorphiaOrg/morphia
private void readMappedField(final Datastore datastore, final MappedField mf, final Object entity, final EntityCache cache,
final DBObject dbObject) {
CustomMapper selectedMapper = mapperCache.get(mf);
if (selectedMapper == null) {
selectedMapper = selectMapper(mf);
mapperCache.put(mf, selectedMapper);
}
selectedMapper.fromDBObject(datastore, dbObject, mf, entity, cache, this);
}
代码示例来源:origin: spotbugs/spotbugs
private void addExceptionHandler(CodeExceptionGen exceptionHandler) {
InstructionHandle handlerPC = exceptionHandler.getHandlerPC();
CodeExceptionGen existing = startInstructionToHandlerMap.get(handlerPC);
if (existing != null) {
exceptionHandler = merge (this.merger, existing, exceptionHandler);
}
startInstructionToHandlerMap.put(handlerPC, exceptionHandler);
}
代码示例来源:origin: robovm/robovm
@Callback
private static void copy(ObjCBlock dst, ObjCBlock src) {
// Called from the Objective-C side every time the block is copied.
// Increase the ref count of the block object on the Java side to
// prevent it from being GCed.
Object blockObj = src.object();
Wrapper wrapper = src.wrapper();
IdentityHashMap<Object, AtomicInteger> refCounts = wrapper.refCounts;
synchronized (refCounts) {
AtomicInteger count = refCounts.get(blockObj);
if (count == null) {
count = new AtomicInteger(0);
refCounts.put(blockObj, count);
}
count.incrementAndGet();
}
}
代码示例来源:origin: apache/ignite
/**
* @param expression Expression.
* @param calcTypes Calculate types for all the expressions.
* @return Parsed expression.
*/
private GridSqlElement parseExpression(@Nullable Expression expression, boolean calcTypes) {
if (expression == null)
return null;
GridSqlElement res = (GridSqlElement)h2ObjToGridObj.get(expression);
if (res == null) {
res = parseExpression0(expression, calcTypes);
if (calcTypes)
res.resultType(fromExpression(expression));
h2ObjToGridObj.put(expression, res);
}
return res;
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
public void exitOr(OrExpression expr) {
final CodeBlock left = codeSnippet.get(expr.left());
final CodeBlock right = codeSnippet.get(expr.right());
codeSnippet.put(expr, CodeBlock.of("($L || $L)", blockOrMissing(left, expr.left()), blockOrMissing(right, expr.right())));
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
public void exitBooleanFuncWrapper(BooleanValuedFunctionWrapper expr) {
final CodeBlock embeddedExpr = codeSnippet.get(expr.expression());
// simply forward the other expression's code
codeSnippet.put(expr, CodeBlock.of("$L", blockOrMissing(embeddedExpr, expr.expression())));
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
public void exitAnd(AndExpression expr) {
final CodeBlock left = codeSnippet.get(expr.left());
final CodeBlock right = codeSnippet.get(expr.right());
codeSnippet.put(expr, CodeBlock.of("($L && $L)", blockOrMissing(left, expr.left()), blockOrMissing(right, expr.right())));
}
内容来源于网络,如有侵权,请联系作者删除!