本文整理汇总了Java中java.util.IdentityHashMap.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java IdentityHashMap.containsKey方法的具体用法?Java IdentityHashMap.containsKey怎么用?Java IdentityHashMap.containsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.IdentityHashMap
的用法示例。
在下文中一共展示了IdentityHashMap.containsKey方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sizedelta
import java.util.IdentityHashMap; //导入方法依赖的package包/类
/**
* Estimates the full size of the object graph rooted at 'obj' by pre-populating the "visited" set with the object
* graph rooted at 'base'. The net effect is to compute the size of 'obj' by summing over all instance data
* contained in 'obj' but not in 'base'.
*
* @param base graph boundary [may not be null]
* @param obj input object instance to be measured
* @return 'obj' size [0 if 'obj' is null']
*/
public static long sizedelta(final Object base, final Object obj) {
if (null == obj || isSharedFlyweight(obj)) {
return 0;
}
if (null == base) {
throw new IllegalArgumentException("null input: base");
}
final IdentityHashMap visited = new IdentityHashMap(40000);
try {
computeSizeof(base, visited, CLASS_METADATA_CACHE);
return visited.containsKey(obj) ? 0 : computeSizeof(obj, visited, CLASS_METADATA_CACHE);
} catch (RuntimeException re) {
// re.printStackTrace();//DEBUG
return -1;
} catch (NoClassDefFoundError ncdfe) {
// BUG: throws "java.lang.NoClassDefFoundError: org.eclipse.core.resources.IWorkspaceRoot" when run in WSAD
// 5
// see
// http://www.javaworld.com/javaforums/showflat.php?Cat=&Board=958763&Number=15235&page=0&view=collapsed&sb=5&o=
// System.err.println(ncdfe);//DEBUG
return -1;
}
}
示例2: commit
import java.util.IdentityHashMap; //导入方法依赖的package包/类
private void commit () {
final List<Work> first = new LinkedList<Work>();
final List<Work> rest = new LinkedList<Work>();
final IdentityHashMap<Work,Work> seenDelete = new IdentityHashMap<Work, Work>();
final Map<URL,Map<String,Pair<FileEventLog.FileOp,Work>>> myChanges = getChanges(false);
if (myChanges != null) {
for (Map<String,Pair<FileOp,Work>> changesInRoot : myChanges.values()) {
for (Pair<FileOp,Work> desc : changesInRoot.values()) {
if (desc.first() == FileOp.DELETE) {
if (!seenDelete.containsKey(desc.second())) {
first.add(desc.second());
seenDelete.put(desc.second(), desc.second());
}
}
else {
rest.add(desc.second());
}
}
}
}
final RepositoryUpdater ru = RepositoryUpdater.getDefault();
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("SCHEDULING: " + first); //NOI18N
}
ru.scheduleWork(first);
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("SCHEDULING: " + rest); //NOI18N
}
ru.scheduleWork(rest);
}
示例3: createDescriptorIfAbsent
import java.util.IdentityHashMap; //导入方法依赖的package包/类
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;
}
}
示例4: buildDuplicateFlags
import java.util.IdentityHashMap; //导入方法依赖的package包/类
private static boolean[] buildDuplicateFlags(MediaSource[] mediaSources) {
boolean[] duplicateFlags = new boolean[mediaSources.length];
IdentityHashMap<MediaSource, Void> sources = new IdentityHashMap<>(mediaSources.length);
for (int i = 0; i < mediaSources.length; i++) {
MediaSource source = mediaSources[i];
if (!sources.containsKey(source)) {
sources.put(source, null);
} else {
duplicateFlags[i] = true;
}
}
return duplicateFlags;
}
示例5: sizedelta
import java.util.IdentityHashMap; //导入方法依赖的package包/类
/**
* Estimates the full size of the object graph rooted at 'obj' by
* pre-populating the "visited" set with the object graph rooted
* at 'base'. The net effect is to compute the size of 'obj' by summing
* over all instance data contained in 'obj' but not in 'base'.
*
* @param base graph boundary [may not be null]
* @param obj input object instance to be measured
* @return 'obj' size [0 if 'obj' is null']
*/
public static int sizedelta (final Object base, final Object obj)
{
if (obj == null) return 0;
if (base == null) throw new IllegalArgumentException ("null input: base");
final IdentityHashMap visited = new IdentityHashMap ();
computeSizeof (base, visited, CLASS_METADATA_CACHE);
return visited.containsKey (obj) ? 0 : computeSizeof (obj, visited, CLASS_METADATA_CACHE);
}
示例6: submitStateUpdateTasks
import java.util.IdentityHashMap; //导入方法依赖的package包/类
/**
* Submits a batch of cluster state update tasks; submitted updates are guaranteed to be processed together,
* potentially with more tasks of the same executor.
*
* @param source the source of the cluster state update task
* @param tasks a map of update tasks and their corresponding listeners
* @param config the cluster state update task configuration
* @param executor the cluster state update task executor; tasks
* that share the same executor will be executed
* batches on this executor
* @param <T> the type of the cluster state update task state
*
*/
public <T> void submitStateUpdateTasks(final String source,
final Map<T, ClusterStateTaskListener> tasks, final ClusterStateTaskConfig config,
final ClusterStateTaskExecutor<T> executor) {
if (!lifecycle.started()) {
return;
}
if (tasks.isEmpty()) {
return;
}
try {
@SuppressWarnings("unchecked")
ClusterStateTaskExecutor<Object> taskExecutor = (ClusterStateTaskExecutor<Object>) executor;
// convert to an identity map to check for dups based on update tasks semantics of using identity instead of equal
final IdentityHashMap<Object, ClusterStateTaskListener> tasksIdentity = new IdentityHashMap<>(tasks);
final List<UpdateTask> updateTasks = tasksIdentity.entrySet().stream().map(
entry -> new UpdateTask(source, entry.getKey(), config.priority(), taskExecutor, safe(entry.getValue(), logger))
).collect(Collectors.toList());
synchronized (updateTasksPerExecutor) {
LinkedHashSet<UpdateTask> existingTasks = updateTasksPerExecutor.computeIfAbsent(executor,
k -> new LinkedHashSet<>(updateTasks.size()));
for (UpdateTask existing : existingTasks) {
if (tasksIdentity.containsKey(existing.task)) {
throw new IllegalStateException("task [" + taskExecutor.describeTasks(Collections.singletonList(existing.task)) +
"] with source [" + source + "] is already queued");
}
}
existingTasks.addAll(updateTasks);
}
final UpdateTask firstTask = updateTasks.get(0);
final TimeValue timeout = config.timeout();
if (timeout != null) {
threadPoolExecutor.execute(firstTask, threadPool.scheduler(), timeout, () -> onTimeout(updateTasks, source, timeout));
} else {
threadPoolExecutor.execute(firstTask);
}
} catch (EsRejectedExecutionException e) {
// ignore cases where we are shutting down..., there is really nothing interesting
// to be done here...
if (!lifecycle.stoppedOrClosed()) {
throw e;
}
}
}
示例7: processObject
import java.util.IdentityHashMap; //导入方法依赖的package包/类
private Object processObject(Object parent, Property property, Object object, Class<?> declaredType,
IdentityHashMap<Object, Object> map, Map<Object, Object> evictees, InitialiserCallback callback,
List<PropertySet> propsToSet)
{
if( object == null )
{
return null;
}
Object newObject = object;
if( map.containsKey(object) )
{
return map.get(object);
}
if( declaredType == null )
{
declaredType = object.getClass();
}
if( Map.class.isAssignableFrom(declaredType) )
{
return processMap(parent, property, (Map<?, ?>) object, map, evictees, callback, propsToSet);
}
if( Collection.class.isAssignableFrom(declaredType) )
{
return processCollection(parent, property, (Collection<?>) object, map, evictees, callback, propsToSet);
}
if( needsSimplify(parent, property, newObject) )
{
newObject = doSimplify(newObject, callback);
return newObject;
}
if( newObject instanceof HibernateProxy )
{
newObject = unwrapHibernate(newObject);
}
map.put(object, newObject);
List<Property> properties = getCacheObject(newObject.getClass()).getProperties();
for( Property prop : properties )
{
Object value = processObject(newObject, prop, prop.get(newObject), prop.getReturnType(), map, evictees,
callback, propsToSet);
propsToSet.add(new PropertySet(object, prop, value));
}
evictees.put(object, object);
return newObject;
}
示例8: initialiseClones
import java.util.IdentityHashMap; //导入方法依赖的package包/类
private void initialiseClones(Object object, IdentityHashMap<Object, Object> previous, Map<Object, Object> evictees,
Object parent, Property property)
{
if( object == null || previous.containsKey(object) )
{
return;
}
Class<? extends Object> clazz = object.getClass();
if( clazz.isArray() || clazz.isPrimitive() || clazz.getPackage().getName().equals("java.lang") ) //$NON-NLS-1$
{
return;
}
if( property != null
&& (property.isDoNotClone() || (getCacheObject(clazz).isEntity() && !(object instanceof IdCloneable))) )
{
return;
}
previous.put(object, object);
if( object instanceof Collection )
{
Collection<?> col = (Collection<?>) object;
for( Object colObj : col )
{
initialiseClones(unwrapHibernate(colObj), previous, evictees, parent, property);
}
}
else if( object instanceof Map )
{
initialiseClones(((Map<?, ?>) object).keySet(), previous, evictees, parent, property);
initialiseClones(((Map<?, ?>) object).values(), previous, evictees, parent, property);
}
else
{
List<Property> properties = getCacheObject(clazz).getProperties();
for( Property childProp : properties )
{
initialiseClones(unwrapHibernate(childProp.get(object)), previous, evictees, object, childProp);
}
}
evictees.put(object, object);
if( object instanceof IdCloneable )
{
((IdCloneable) object).setId(0);
}
}