本文整理汇总了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());
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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());
}
示例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();
}
}
示例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);
}
示例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;
}