com.google.common.collect.Maps.newIdentityHashMap()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(152)

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

Maps.newIdentityHashMap介绍

[英]Creates an IdentityHashMap instance.
[中]创建IdentityHashMap实例。

代码示例

代码示例来源:origin: google/guava

/**
 * Creates an empty {@code Set} that uses identity to determine equality. It compares object
 * references, instead of calling {@code equals}, to determine whether a provided object matches
 * an element in the set. For example, {@code contains} returns {@code false} when passed an
 * object that equals a set member, but isn't the same instance. This behavior is similar to the
 * way {@code IdentityHashMap} handles key lookups.
 *
 * @since 8.0
 */
public static <E> Set<E> newIdentityHashSet() {
 return Collections.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap());
}

代码示例来源:origin: google/j2objc

/**
 * Creates an empty {@code Set} that uses identity to determine equality. It compares object
 * references, instead of calling {@code equals}, to determine whether a provided object matches
 * an element in the set. For example, {@code contains} returns {@code false} when passed an
 * object that equals a set member, but isn't the same instance. This behavior is similar to the
 * way {@code IdentityHashMap} handles key lookups.
 *
 * @since 8.0
 */
public static <E> Set<E> newIdentityHashSet() {
 return Collections.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap());
}

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

public TsConditionEraser(TblColRef tsColumn, TupleFilter root) {
  this.tsColumn = tsColumn;
  this.root = root;
  this.isInTopLevelANDs = Maps.newIdentityHashMap();
}

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

public TimeConditionLiteralsReplacer(TupleFilter root) {
  this.dateCompareTupleChildren = Maps.newIdentityHashMap();
}

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

/**
 * Creates an empty {@code Set} that uses identity to determine equality. It compares object
 * references, instead of calling {@code equals}, to determine whether a provided object matches
 * an element in the set. For example, {@code contains} returns {@code false} when passed an
 * object that equals a set member, but isn't the same instance. This behavior is similar to the
 * way {@code IdentityHashMap} handles key lookups.
 *
 * @since 8.0
 */
public static <E> Set<E> newIdentityHashSet() {
 return Collections.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap());
}

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

private Function<Object, Integer> bindingsToSourceOrder(SourceTypeBinding sourceBinding) {
  IdentityHashMap<Object, Integer> bindings = Maps.newIdentityHashMap();
  if (sourceBinding.scope.referenceContext.methods != null) {
   for (AbstractMethodDeclaration declaration : sourceBinding.scope.referenceContext.methods) {
    bindings.put(declaration.binding, declaration.declarationSourceStart);
   }
  }
  if (sourceBinding.scope.referenceContext.fields != null) {
   for (FieldDeclaration declaration : sourceBinding.scope.referenceContext.fields) {
    bindings.put(declaration.binding, declaration.declarationSourceStart);
   }
  }
  if (sourceBinding.scope.referenceContext.memberTypes != null) {
   for (TypeDeclaration declaration : sourceBinding.scope.referenceContext.memberTypes) {
    bindings.put(declaration.binding, declaration.declarationSourceStart);
   }
  }
  return Functions.forMap(bindings);
 }
}

代码示例来源:origin: google/guava

public void testIdentityHashMap() {
 IdentityHashMap<Integer, Integer> map = Maps.newIdentityHashMap();
 assertEquals(Collections.emptyMap(), map);
}

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

@Override
public CompletableFuture<Boolean> prepare(TransactionLog<MapUpdate<K, byte[]>> transactionLog) {
 Map<PartitionId, List<MapUpdate<K, byte[]>>> updatesGroupedByMap = Maps.newIdentityHashMap();
 transactionLog.records().forEach(update -> {
  updatesGroupedByMap.computeIfAbsent(getProxyClient().getPartitionId(update.key().toString()), k -> Lists.newLinkedList()).add(update);
 });
 Map<PartitionId, TransactionLog<MapUpdate<K, byte[]>>> transactionsByMap =
   Maps.transformValues(updatesGroupedByMap, list -> new TransactionLog<>(transactionLog.transactionId(), transactionLog.version(), list));
 return Futures.allOf(transactionsByMap.entrySet()
   .stream()
   .map(e -> getProxyClient().applyOn(e.getKey(), service -> service.prepare(e.getValue()))
     .thenApply(v -> v == PrepareResult.OK || v == PrepareResult.PARTIAL_FAILURE))
   .collect(Collectors.toList()))
   .thenApply(list -> list.stream().reduce(Boolean::logicalAnd).orElse(true));
}

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

@Override
public CompletableFuture<Boolean> prepare(TransactionLog<SetUpdate<String>> transactionLog) {
 Map<PartitionId, List<SetUpdate<String>>> updatesGroupedBySet = Maps.newIdentityHashMap();
 transactionLog.records().forEach(update -> {
  updatesGroupedBySet.computeIfAbsent(getProxyClient().getPartitionId(update.element()), k -> Lists.newLinkedList()).add(update);
 });
 Map<PartitionId, TransactionLog<SetUpdate<String>>> transactionsBySet =
   Maps.transformValues(updatesGroupedBySet, list -> new TransactionLog<>(transactionLog.transactionId(), transactionLog.version(), list));
 return Futures.allOf(transactionsBySet.entrySet()
   .stream()
   .map(e -> getProxyClient().applyOn(e.getKey(), service -> service.prepare(e.getValue()))
     .thenApply(v -> v == PrepareResult.OK || v == PrepareResult.PARTIAL_FAILURE))
   .collect(Collectors.toList()))
   .thenApply(list -> list.stream().reduce(Boolean::logicalAnd).orElse(true));
}

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

public PulsarClientImpl(ClientConfigurationData conf, EventLoopGroup eventLoopGroup, ConnectionPool cnxPool)
    throws PulsarClientException {
  if (conf == null || isBlank(conf.getServiceUrl()) || eventLoopGroup == null) {
    throw new PulsarClientException.InvalidConfigurationException("Invalid client configuration");
  }
  this.eventLoopGroup = eventLoopGroup;
  this.conf = conf;
  conf.getAuthentication().start();
  this.cnxPool = cnxPool;
  externalExecutorProvider = new ExecutorProvider(conf.getNumListenerThreads(), getThreadFactory("pulsar-external-listener"));
  if (conf.getServiceUrl().startsWith("http")) {
    lookup = new HttpLookupService(conf, eventLoopGroup);
  } else {
    lookup = new BinaryProtoLookupService(this, conf.getServiceUrl(), conf.isUseTls(), externalExecutorProvider.getExecutor());
  }
  timer = new HashedWheelTimer(getThreadFactory("pulsar-timer"), 1, TimeUnit.MILLISECONDS);
  producers = Maps.newIdentityHashMap();
  consumers = Maps.newIdentityHashMap();
  state.set(State.Open);
}

代码示例来源:origin: org.apache.apex/malhar-library

/**
 * @param counterType type of counter
 */
public BasicCounters(@Nonnull Class<T> counterType)
{
 cache = Maps.newIdentityHashMap();
 this.counterType = counterType;
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/**
 * Creates an empty {@code Set} that uses identity to determine equality. It compares object
 * references, instead of calling {@code equals}, to determine whether a provided object matches
 * an element in the set. For example, {@code contains} returns {@code false} when passed an
 * object that equals a set member, but isn't the same instance. This behavior is similar to the
 * way {@code IdentityHashMap} handles key lookups.
 *
 * @since 8.0
 */
public static <E> Set<E> newIdentityHashSet() {
 return Collections.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap());
}

代码示例来源:origin: no.ssb.vtl/java-vtl-model

private static IdentityHashMap<Component, String> computeInverseCache(ImmutableMap<String, Component> delegate) {
  IdentityHashMap<Component, String> map = Maps.newIdentityHashMap();
  for (Entry<String, Component> entry : delegate.entrySet()) {
    map.put(entry.getValue(), entry.getKey());
  }
  return map;
}

代码示例来源:origin: org.aksw.commons/subgraph-isomorphism-index-core

public static <K, V> SetMultimap<K, V> newSetMultimap(boolean identityKeys, boolean identityValues) {
  Map<K, Collection<V>> keys = identityKeys ? Maps.newIdentityHashMap() : new LinkedHashMap<>();
  com.google.common.base.Supplier<Set<V>> values = identityValues ? Sets::newIdentityHashSet : LinkedHashSet::new;
  return Multimaps.newSetMultimap(keys, values);
}

代码示例来源:origin: org.eclipse/xtext

protected Map<EObject, IEObjectDescription> createEObject2ExportedEObjectsMap(
    Iterable<IEObjectDescription> exportedObjects) {
  Map<EObject, IEObjectDescription> uri2exportedEObjects = Maps.newIdentityHashMap();
  for (IEObjectDescription eObjectDescription : exportedObjects) {
    uri2exportedEObjects.put(eObjectDescription.getEObjectOrProxy(), eObjectDescription);
  }
  return uri2exportedEObjects;
}

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

private BeanDynamicObject asDynamicObject(Object object) {
    if (dynamicObjects == null) {
      dynamicObjects = Maps.newIdentityHashMap();
    }
    BeanDynamicObject dynamicObject = dynamicObjects.get(object);
    if (dynamicObject == null) {
      dynamicObject = new BeanDynamicObject(object);
      dynamicObjects.put(object, dynamicObject);
    }
    return dynamicObject;
  }
}

代码示例来源:origin: co.cask.tigon/tigon-common

@SuppressWarnings("unchecked")
public ReflectionDatumReader(Schema schema, TypeToken<T> type) {
 this.schema = schema;
 this.type = type;
 this.creatorFactory = new InstantiatorFactory(true);
 this.creators = Maps.newIdentityHashMap();
 this.fieldAccessorFactory = new ReflectionFieldAccessorFactory();
}

代码示例来源:origin: com.mycila.guice.extensions/mycila-guice-servlet

public void destroy() {
  Set<HttpServlet> destroyedSoFar
    = Sets.newSetFromMap(Maps.<HttpServlet, Boolean>newIdentityHashMap());
  for (ServletDefinition servletDefinition : servletDefinitions) {
    servletDefinition.destroy(destroyedSoFar);
  }
}

代码示例来源:origin: caskdata/cdap

protected ReflectionReader(Schema schema, TypeToken<TO> type) {
 this.creatorFactory = new InstantiatorFactory(true);
 this.creators = Maps.newIdentityHashMap();
 this.fieldAccessorFactory = new ReflectionFieldAccessorFactory();
 this.schema = schema;
 this.type = type;
}

代码示例来源:origin: co.cask.cdap/cdap-common

protected ReflectionReader(Schema schema, TypeToken<TO> type) {
 this.creatorFactory = new InstantiatorFactory(true);
 this.creators = Maps.newIdentityHashMap();
 this.fieldAccessorFactory = new ReflectionFieldAccessorFactory();
 this.schema = schema;
 this.type = type;
}

相关文章