当前位置: 首页>>代码示例>>Java>>正文


Java Maps.newHashMapWithExpectedSize方法代码示例

本文整理汇总了Java中com.google.common.collect.Maps.newHashMapWithExpectedSize方法的典型用法代码示例。如果您正苦于以下问题:Java Maps.newHashMapWithExpectedSize方法的具体用法?Java Maps.newHashMapWithExpectedSize怎么用?Java Maps.newHashMapWithExpectedSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Maps的用法示例。


在下文中一共展示了Maps.newHashMapWithExpectedSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MainDexListBuilder

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * @param baseClasses Classes which code may be executed before secondary dex files loading.
 * @param application the dex appplication.
 */
public MainDexListBuilder(Set<DexType> baseClasses, DexApplication application) {
  this.dexApplication = application;
  this.appInfo = new AppInfoWithSubtyping(dexApplication);
  this.baseClasses =
      baseClasses.stream().filter(this::isProgramClass).collect(Collectors.toSet());
  enumTypes = appInfo.subtypes(appInfo.dexItemFactory.enumType);
  if (enumTypes == null) {
    throw new CompilationError("Tracing for legacy multi dex is not possible without all"
        + " classpath libraries (java.lang.Enum is missing)");
  }
  annotationTypes = appInfo.subtypes(appInfo.dexItemFactory.annotationType);
  if (annotationTypes == null) {
    throw new CompilationError("Tracing for legacy multi dex is not possible without all"
        + " classpath libraries (java.lang.annotation.Annotation is missing)");
  }
  annotationTypeContainEnum = Maps.newHashMapWithExpectedSize(annotationTypes.size());
}
 
开发者ID:inferjay,项目名称:r8,代码行数:22,代码来源:MainDexListBuilder.java

示例2: MetaJavaBean

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Creates a new MetaJavaBean with random fields.
 * 
 * @param fqn
 *            The fully qualified name of the bean's class.
 * @param numFields
 *            Number of simple type fields that will be added.
 */
public MetaJavaBean(JCodeModel cm, String fqn, int numFields) {

    super(cm, fqn, ClassType.CLASS);

    // Empty constructor
    getGeneratedClass().constructor(JMod.PUBLIC);

    // Init the simple fields
    this.fields = Maps.newHashMapWithExpectedSize(numFields);
    for (int i = 0; i < numFields; ++i) {
        String fieldName = "field" + Config.CFG.nextUniqueNum();
        JavaBeanBasicField field = new JavaBeanBasicField(this, fieldName);
        fields.put(fieldName, field);
    }

}
 
开发者ID:hibernate,项目名称:beanvalidation-benchmark,代码行数:25,代码来源:MetaJavaBean.java

示例3: hasCycle

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Returns true if {@code graph} has at least one cycle. A cycle is defined as a non-empty subset
 * of edges in a graph arranged to form a path (a sequence of adjacent outgoing edges) starting
 * and ending with the same node.
 *
 * <p>This method will detect any non-empty cycle, including self-loops (a cycle of length 1).
 */
public static boolean hasCycle(Graph<?> graph) {
  int numEdges = graph.edges().size();
  if (numEdges == 0) {
    return false; // An edge-free graph is acyclic by definition.
  }
  if (!graph.isDirected() && numEdges >= graph.nodes().size()) {
    return true; // Optimization for the undirected case: at least one cycle must exist.
  }

  Map<Object, NodeVisitState> visitedNodes =
      Maps.newHashMapWithExpectedSize(graph.nodes().size());
  for (Object node : graph.nodes()) {
    if (subgraphHasCycle(graph, visitedNodes, node, null)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:26,代码来源:Graphs.java

示例4: getMultipleUserInfosFromSingleInfos

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public static Map<String, UserBean> getMultipleUserInfosFromSingleInfos(UserDirectory ud, Collection<String> userIds)
{
	Map<String, UserBean> rv = null;
	for( String userId : userIds )
	{
		UserBean ub = ud.getInformationForUser(userId);
		if( ub != null )
		{
			if( rv == null )
			{
				rv = Maps.newHashMapWithExpectedSize(userIds.size());
			}
			rv.put(userId, ub);
		}
	}
	return rv;
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:UserDirectoryUtils.java

示例5: getMultipleGroupInfosFromSingleInfos

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public static Map<String, GroupBean> getMultipleGroupInfosFromSingleInfos(UserDirectory ud,
	Collection<String> groupIds)
{
	Map<String, GroupBean> rv = null;
	for( String groupID : groupIds )
	{
		GroupBean gb = ud.getInformationForGroup(groupID);
		if( gb != null )
		{
			if( rv == null )
			{
				rv = Maps.newHashMapWithExpectedSize(groupIds.size());
			}
			rv.put(groupID, gb);
		}
	}
	return rv;
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:UserDirectoryUtils.java

示例6: appendNode

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
public void appendNode(Node parentNode) {
    Map<String, Object> attributes = Maps.newHashMapWithExpectedSize(2);
    attributes.put("deploy-path", deployPath);
    attributes.put("handle", handle);
    Node node = parentNode.appendNode("dependent-module", attributes);
    node.appendNode("dependency-type").setValue("uses");
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:WbDependentModule.java

示例7: getSnapshotDirs

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Retrieve the directories into which snapshots have been restored from
 * ({@link #RESTORE_DIRS_KEY})
 *
 * @param conf Configuration to extract restore directories from
 * @return the directories into which snapshots have been restored from
 * @throws IOException
 */
public Map<String, Path> getSnapshotDirs(Configuration conf) throws IOException {
  List<Map.Entry<String, String>> kvps = ConfigurationUtil.getKeyValues(conf, RESTORE_DIRS_KEY);
  Map<String, Path> rtn = Maps.newHashMapWithExpectedSize(kvps.size());

  for (Map.Entry<String, String> kvp : kvps) {
    rtn.put(kvp.getKey(), new Path(kvp.getValue()));
  }

  return rtn;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:MultiTableSnapshotInputFormatImpl.java

示例8: getBucketByKey

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
public Terms.Bucket getBucketByKey(String term) {
    if (bucketMap == null) {
        bucketMap = Maps.newHashMapWithExpectedSize(buckets.size());
        for (Bucket bucket : buckets) {
            bucketMap.put(bucket.getKeyAsString(), bucket);
        }
    }
    return bucketMap.get(term);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:InternalTerms.java

示例9: findOrCreateBytecodeLevelConfiguration

import com.google.common.collect.Maps; //导入方法依赖的package包/类
private Node findOrCreateBytecodeLevelConfiguration() {
    Node compilerConfiguration = findCompilerConfiguration();
    if (compilerConfiguration == null) {
        Map<String, Object> attributes = Maps.newHashMapWithExpectedSize(1);
        attributes.put("name", "CompilerConfiguration");
        compilerConfiguration = getXml().appendNode("component", attributes);
    }
    return findOrCreateFirstChildNamed(compilerConfiguration, "bytecodeTargetLevel");
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:Project.java

示例10: getObjectName

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public ObjectName getObjectName(ModuleRpcs rpcMapping) {
    Map<String, String> additionalAttributesJavaNames = Maps
            .newHashMapWithExpectedSize(additionalAttributes.size());
    for (String attributeYangName : additionalAttributes.keySet()) {
        String attributeJavaName = rpcMapping.getRbeJavaName(attributeYangName);
        Preconditions.checkState(attributeJavaName != null,
                "Cannot find java name for runtime bean wtih yang name %s", attributeYangName);
        additionalAttributesJavaNames.put(attributeJavaName, additionalAttributes.get(attributeYangName));
    }
    return ObjectNameUtil.createRuntimeBeanName(moduleName, instanceName, additionalAttributesJavaNames);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:12,代码来源:RuntimeRpcElementResolved.java

示例11: DictionaryAidedDepluralizer

import com.google.common.collect.Maps; //导入方法依赖的package包/类
DictionaryAidedDepluralizer(String[] exceptions) {
  Map<String, String> map = Maps.newHashMapWithExpectedSize(exceptions.length);
  Splitter splitter = Splitter.on(':');
  for (String s : exceptions) {
    List<String> parts = splitter.splitToList(s.toLowerCase());
    if (parts.size() == 1) {
      // simple no-depluratization exception
      map.put(parts.get(0), parts.get(0));
    } else if (parts.size() == 2) {
      // singular, then plural, so mapping plural->singular
      map.put(parts.get(1), parts.get(0));
    }
  }
  this.dictionary = ImmutableMap.copyOf(map);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:Depluralizer.java

示例12: setupLoadOnly

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public void setupLoadOnly(String deobfFileName, boolean loadAll)
{
    try
    {
        File mapData = new File(deobfFileName);
        LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData));
        CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
        List<String> srgList = srgSource.readLines();
        rawMethodMaps = Maps.newHashMap();
        rawFieldMaps = Maps.newHashMap();
        Builder<String, String> builder = ImmutableBiMap.builder();
        Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
        for (String line : srgList)
        {
            String[] parts = Iterables.toArray(splitter.split(line),String.class);
            String typ = parts[0];
            if ("CL".equals(typ))
            {
                parseClass(builder, parts);
            }
            else if ("MD".equals(typ) && loadAll)
            {
                parseMethod(parts);
            }
            else if ("FD".equals(typ) && loadAll)
            {
                parseField(parts);
            }
        }
        classNameBiMap = builder.build();
    }
    catch (IOException ioe)
    {
        FMLRelaunchLog.log(Level.ERROR, "An error occurred loading the deobfuscation map data", ioe);
    }
    methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
    fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());

}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:40,代码来源:FMLDeobfuscatingRemapper.java

示例13: createMap

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/** Returns an empty mutable map whose keys will respect this {@link ElementOrder}. */
<K extends T, V> Map<K, V> createMap(int expectedSize) {
  switch (type) {
    case UNORDERED:
      return Maps.newHashMapWithExpectedSize(expectedSize);
    case INSERTION:
      return Maps.newLinkedHashMapWithExpectedSize(expectedSize);
    case SORTED:
      return Maps.newTreeMap(comparator());
    default:
      throw new AssertionError();
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:14,代码来源:ElementOrder.java

示例14: lookupMap

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public static <T, E extends Enum<E>> Function<T, E> lookupMap(E[] values, Function<E, T> mapper) {
    Map<T, E> index = Maps.newHashMapWithExpectedSize(values.length);
    for (E value : values) {
        index.put(mapper.apply(value), value);
    }
    return (T key) -> index.get(key);
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:8,代码来源:EnumUtils.java

示例15: getInformationForUsers

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
public Map<String, UserBean> getInformationForUsers(final Collection<String> userIds)
{
	Map<String, UserBean> rv = Maps.newHashMapWithExpectedSize(userIds.size());
	for( TLEUser tleu : tleUserService.getInformationForUsers(userIds) )
	{
		UserBean ub = convert(tleu);
		rv.put(ub.getUniqueID(), ub);
	}
	return rv;
}
 
开发者ID:equella,项目名称:Equella,代码行数:12,代码来源:TLEUserWrapper.java


注:本文中的com.google.common.collect.Maps.newHashMapWithExpectedSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。