當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。