• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HashMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.util.containers.hash.HashMap的典型用法代码示例。如果您正苦于以下问题:Java HashMap类的具体用法?Java HashMap怎么用?Java HashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HashMap类属于com.intellij.util.containers.hash包,在下文中一共展示了HashMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getChildMap

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
public static <K, V> Map<K, V> getChildMap(Element element, String name, boolean optional) throws StudyUnrecognizedFormatException {
  Element mapParent = getChildWithName(element, name, optional);
  if (mapParent != null) {
    Element map = mapParent.getChild(MAP);
    if (map != null) {
      HashMap result = new HashMap();
      for (Element entry : map.getChildren()) {
        Object key = entry.getAttribute(KEY) == null ? entry.getChild(KEY).getChildren().get(0) : entry.getAttributeValue(KEY);
        Object value = entry.getAttribute(VALUE) == null ? entry.getChild(VALUE).getChildren().get(0) : entry.getAttributeValue(VALUE);
        result.put(key, value);
      }
      return result;
    }
  }
  return Collections.emptyMap();
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:StudySerializationUtils.java


示例2: groupByVcs

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
private static Map<VcsCherryPicker, List<VcsFullCommitDetails>> groupByVcs(@NotNull Project project,
                                                                           @NotNull List<VcsFullCommitDetails> commits) {
  final ProjectLevelVcsManager projectLevelVcsManager = ProjectLevelVcsManager.getInstance(project);
  Map<VcsCherryPicker, List<VcsFullCommitDetails>> resultMap = new HashMap<VcsCherryPicker, List<VcsFullCommitDetails>>();
  for (VcsFullCommitDetails commit : commits) {
    VcsCherryPicker cherryPicker = getCherryPickerForCommit(project, projectLevelVcsManager, commit);
    if (cherryPicker == null) {
      LOG.warn("Cherry pick is not supported for " + commit.getRoot().getName());
      return Collections.emptyMap();
    }
    List<VcsFullCommitDetails> list = resultMap.get(cherryPicker);
    if (list == null) {
      resultMap.put(cherryPicker, list = new ArrayList<VcsFullCommitDetails>()); // ordered set!!
    }
    list.add(commit);
  }
  return resultMap;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:VcsCherryPickAction.java


示例3: filterUsages

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
protected List<UsageInfo> filterUsages(List<UsageInfo> infos) {
  Map<PsiElement, MoveRenameUsageInfo> moveRenameInfos = new HashMap<PsiElement, MoveRenameUsageInfo>();
  Set<PsiElement> usedElements = new HashSet<PsiElement>();

  List<UsageInfo> result = new ArrayList<UsageInfo>(infos.size() / 2);
  for (UsageInfo info : infos) {
    LOG.assertTrue(info != null, getClass());
    PsiElement element = info.getElement();
    if (info instanceof MoveRenameUsageInfo) {
      if (usedElements.contains(element)) continue;
      moveRenameInfos.put(element, (MoveRenameUsageInfo)info);
    }
    else {
      moveRenameInfos.remove(element);
      usedElements.add(element);
      if (!(info instanceof PossiblyIncorrectUsage) || ((PossiblyIncorrectUsage)info).isCorrect()) {
        result.add(info);
      }
    }
  }
  result.addAll(moveRenameInfos.values());
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ChangeSignatureProcessorBase.java


示例4: collectManagingDependencies

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
@NotNull
public static Map<DependencyConflictId, MavenDomDependency> collectManagingDependencies(@NotNull final MavenDomProjectModel model) {
  final Map<DependencyConflictId, MavenDomDependency> dependencies = new HashMap<DependencyConflictId, MavenDomDependency>();

  Processor<MavenDomDependency> collectProcessor = new Processor<MavenDomDependency>() {
    public boolean process(MavenDomDependency dependency) {
      DependencyConflictId id = DependencyConflictId.create(dependency);
      if (id != null && !dependencies.containsKey(id)) {
        dependencies.put(id, dependency);
      }

      return false;
    }
  };

  MavenDomProjectProcessorUtils.processDependenciesInDependencyManagement(model, collectProcessor, model.getManager().getProject());

  return dependencies;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GenerateManagedDependencyAction.java


示例5: getApplicationUsages

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
@NotNull
public Set<UsageDescriptor> getApplicationUsages(@NotNull final ApplicationStatisticsPersistence persistence) {
    final Map<String, Integer> result = new HashMap<String, Integer>();

    for (Set<UsageDescriptor> usageDescriptors : persistence.getApplicationData(getGroupId()).values()) {
        for (UsageDescriptor usageDescriptor : usageDescriptors) {
            final String key = usageDescriptor.getKey();
            final Integer count = result.get(key);
            result.put(key, count == null ? 1 : count.intValue() + 1);
        }
    }

    return ContainerUtil.map2Set(result.entrySet(), new Function<Map.Entry<String, Integer>, UsageDescriptor>() {
        @Override
        public UsageDescriptor fun(Map.Entry<String, Integer> entry) {
            return new UsageDescriptor(entry.getKey(), entry.getValue());
        }
    });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:AbstractApplicationUsagesCollector.java


示例6: getApplicationUsages

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
@Nonnull
public Set<UsageDescriptor> getApplicationUsages(@Nonnull final ApplicationStatisticsPersistence persistence) {
    final Map<String, Integer> result = new HashMap<String, Integer>();

    for (Set<UsageDescriptor> usageDescriptors : persistence.getApplicationData(getGroupId()).values()) {
        for (UsageDescriptor usageDescriptor : usageDescriptors) {
            final String key = usageDescriptor.getKey();
            final Integer count = result.get(key);
            result.put(key, count == null ? 1 : count.intValue() + 1);
        }
    }

    return ContainerUtil.map2Set(result.entrySet(), new Function<Map.Entry<String, Integer>, UsageDescriptor>() {
        @Override
        public UsageDescriptor fun(Map.Entry<String, Integer> entry) {
            return new UsageDescriptor(entry.getKey(), entry.getValue());
        }
    });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:AbstractApplicationUsagesCollector.java


示例7: getSiblingInheritanceInfos

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
@NotNull
public static Map<PsiMethod, SiblingInfo> getSiblingInheritanceInfos(@NotNull final Collection<PsiMethod> methods)
{
	MultiMap<PsiClass, PsiMethod> byClass = MultiMap.create();
	for(PsiMethod method : methods)
	{
		PsiClass containingClass = method.getContainingClass();
		if(canHaveSiblingSuper(method, containingClass))
		{
			byClass.putValue(containingClass, method);
		}
	}

	Map<PsiMethod, SiblingInfo> result = new HashMap<>();
	for(PsiClass psiClass : byClass.keySet())
	{
		SiblingInheritorSearcher searcher = new SiblingInheritorSearcher(byClass.get(psiClass), psiClass);
		ClassInheritorsSearch.search(psiClass, psiClass.getUseScope(), true, true, false).forEach(searcher);
		result.putAll(searcher.getResult());
	}
	return result;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:FindSuperElementsHelper.java


示例8: fillStatusMap

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
public static Map<String, String> fillStatusMap(Element taskManagerElement, String mapName, XMLOutputter outputter)
  throws StudyUnrecognizedFormatException {
  Map<Element, String> sourceMap = getChildMap(taskManagerElement, mapName);
  Map<String, String> destMap = new HashMap<>();
  for (Map.Entry<Element, String> entry : sourceMap.entrySet()) {
    String status = entry.getValue();
    if (status.equals(StudyStatus.Unchecked.toString())) {
      continue;
    }
    destMap.put(outputter.outputString(entry.getKey()), status);
  }
  return destMap;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:14,代码来源:StudySerializationUtils.java


示例9: removeIndexFromSubtaskInfos

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
public static void removeIndexFromSubtaskInfos(JsonObject placeholderObject) {
  JsonArray infos = placeholderObject.getAsJsonArray(SUBTASK_INFOS);
  Map<Integer, JsonObject> objectsToInsert = new HashMap<>();
  for (JsonElement info : infos) {
    JsonObject object = info.getAsJsonObject();
    int index = object.getAsJsonPrimitive(INDEX).getAsInt();
    objectsToInsert.put(index, object);
  }
  placeholderObject.remove(SUBTASK_INFOS);
  JsonObject newInfos = new JsonObject();
  placeholderObject.add(SUBTASK_INFOS, newInfos);
  for (Map.Entry<Integer, JsonObject> entry : objectsToInsert.entrySet()) {
    newInfos.add(entry.getKey().toString(), entry.getValue());
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:16,代码来源:StudySerializationUtils.java


示例10: renameFiles

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
/**
 * @param fromIndex -1 if task converted to TaskWithSubtasks, -2 if task converted from TaskWithSubtasks
 */
public static void renameFiles(VirtualFile taskDir, Project project, int fromIndex) {
  ApplicationManager.getApplication().runWriteAction(() -> {
    Map<VirtualFile, String> newNames = new HashMap<>();
    for (VirtualFile virtualFile : taskDir.getChildren()) {
      int subtaskIndex = getSubtaskIndex(project, virtualFile);
      if (subtaskIndex == -1) {
        continue;
      }
      if (subtaskIndex > fromIndex) {
        String index;
        if (fromIndex == -1) { // add new subtask
          index = "0";
        }
        else { // remove subtask
          index = fromIndex == -2 ? "" : Integer.toString(subtaskIndex - 1);
        }
        String fileName = virtualFile.getName();
        String nameWithoutExtension = FileUtil.getNameWithoutExtension(fileName);
        String extension = FileUtilRt.getExtension(fileName);
        int subtaskMarkerIndex = nameWithoutExtension.indexOf(EduNames.SUBTASK_MARKER);
        String newName = subtaskMarkerIndex == -1
                         ? nameWithoutExtension
                         : nameWithoutExtension.substring(0, subtaskMarkerIndex);
        newName += index.isEmpty() ? "" : EduNames.SUBTASK_MARKER;
        newName += index + "." + extension;
        newNames.put(virtualFile, newName);
      }
    }
    for (Map.Entry<VirtualFile, String> entry : newNames.entrySet()) {
      try {
        entry.getKey().rename(project, entry.getValue());
      }
      catch (IOException e) {
        LOG.info(e);
      }
    }
  });
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:42,代码来源:CCUtils.java


示例11: setUp

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  myModel = JpsElementFactory.getInstance().createModel();
  myProject = myModel.getProject();
  myDataStorageRoot = FileUtil.createTempDirectory("compile-server-" + getProjectName(), null);
  myLogger = new TestProjectBuilderLogger();
  myBuildParams = new HashMap<String, String>();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JpsBuildTestCase.java


示例12: loadProject

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
protected void loadProject(String projectPath,
                           Map<String, String> pathVariables) {
  try {
    String testDataRootPath = getTestDataRootPath();
    String fullProjectPath = FileUtil.toSystemDependentName(testDataRootPath != null ? testDataRootPath + "/" + projectPath : projectPath);
    Map<String, String> allPathVariables = new HashMap<String, String>(pathVariables.size() + 1);
    allPathVariables.putAll(pathVariables);
    allPathVariables.put(PathMacroUtil.APPLICATION_HOME_DIR, PathManager.getHomePath());
    allPathVariables.putAll(getAdditionalPathVariables());
    JpsProjectLoader.loadProject(myProject, allPathVariables, fullProjectPath);
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:JpsBuildTestCase.java


示例13: getAnchorsToDisplay

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
public Collection<DisplayedFoldingAnchor> getAnchorsToDisplay(int firstVisibleOffset, int lastVisibleOffset, FoldRegion activeFoldRegion) {
  Map<Integer, DisplayedFoldingAnchor> result = new HashMap<Integer, DisplayedFoldingAnchor>();
  FoldRegion[] visibleFoldRegions = myEditor.getFoldingModel().fetchVisible();
  for (FoldRegion region : visibleFoldRegions) {
    if (!region.isValid()) continue;
    final int startOffset = region.getStartOffset();
    if (startOffset > lastVisibleOffset) continue;
    final int endOffset = getEndOffset(region);
    if (endOffset < firstVisibleOffset) continue;
    if (!isFoldingPossible(startOffset, endOffset)) continue;

    final FoldingGroup group = region.getGroup();
    if (group != null && myEditor.getFoldingModel().getFirstRegion(group, region) != region) continue;

    //offset = Math.min(myEditor.getDocument().getTextLength() - 1, offset);
    int foldStart = myEditor.offsetToVisualLine(startOffset);

    if (!region.isExpanded()) {
      tryAdding(result, region, foldStart, 0, DisplayedFoldingAnchor.Type.COLLAPSED, activeFoldRegion);
    }
    else {
      //offset = Math.min(myEditor.getDocument().getTextLength() - 1, offset);
      int foldEnd = myEditor.offsetToVisualLine(endOffset);
      tryAdding(result, region, foldStart, foldEnd - foldStart, DisplayedFoldingAnchor.Type.EXPANDED_TOP, activeFoldRegion);
      tryAdding(result, region, foldEnd, foldEnd - foldStart, DisplayedFoldingAnchor.Type.EXPANDED_BOTTOM, activeFoldRegion);
    }
  }
  return result.values();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:FoldingAnchorsOverlayStrategy.java


示例14: testConvertUsagesWithPriority

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
public void testConvertUsagesWithPriority() {
    final Map<GroupDescriptor, Set<PatchedUsage>> patchedUsages = new HashMap<GroupDescriptor, Set<PatchedUsage>>();

    createPatchDescriptor(patchedUsages, "low", GroupDescriptor.LOWER_PRIORITY, "l1", 1);
    createPatchDescriptor(patchedUsages, "low", GroupDescriptor.LOWER_PRIORITY, "l2", 1);
    createPatchDescriptor(patchedUsages, "high", GroupDescriptor.HIGHER_PRIORITY, "h", 1);
    createPatchDescriptor(patchedUsages, "high", GroupDescriptor.HIGHER_PRIORITY, "h2", 1);
    createPatchDescriptor(patchedUsages, "default_1", GroupDescriptor.DEFAULT_PRIORITY, "d11", 1);
    createPatchDescriptor(patchedUsages, "default_2", GroupDescriptor.DEFAULT_PRIORITY, "d21", 1);
    createPatchDescriptor(patchedUsages, "default_1", GroupDescriptor.DEFAULT_PRIORITY, "d12", 1);


    assertEquals(ConvertUsagesUtil.convertUsages(patchedUsages),
                 "high:h=1,h2=1;default_1:d11=1,d12=1;default_2:d21=1;low:l1=1,l2=1;");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:StatisticsUploadAssistantTest.java


示例15: testConvertUsagesWithEqualPriority

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
public void testConvertUsagesWithEqualPriority() {
      final Map<GroupDescriptor, Set<PatchedUsage>> patchedUsages = new HashMap<GroupDescriptor, Set<PatchedUsage>>();

createPatchDescriptor(patchedUsages, "g4", GroupDescriptor.HIGHER_PRIORITY, "1", 1);
      createPatchDescriptor(patchedUsages, "g2", GroupDescriptor.HIGHER_PRIORITY, "2", 1);
      createPatchDescriptor(patchedUsages, "g1", GroupDescriptor.HIGHER_PRIORITY, "3", 1);
      createPatchDescriptor(patchedUsages, "g3", GroupDescriptor.HIGHER_PRIORITY, "4", 1);


      assertEquals(ConvertUsagesUtil.convertUsages(patchedUsages), "g1:3=1;g2:2=1;g3:4=1;g4:1=1;");
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:StatisticsUploadAssistantTest.java


示例16: testConvertString

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
public void testConvertString() {
    final Map<GroupDescriptor, Set<PatchedUsage>> patchedUsages = new HashMap<GroupDescriptor, Set<PatchedUsage>>();

    createPatchDescriptor(patchedUsages, "g4", GroupDescriptor.HIGHER_PRIORITY, "1", 1);
    createPatchDescriptor(patchedUsages, "g2", GroupDescriptor.HIGHER_PRIORITY, "2", 1);
    createPatchDescriptor(patchedUsages, "g1", GroupDescriptor.HIGHER_PRIORITY, "3", 1);
    createPatchDescriptor(patchedUsages, "g3", GroupDescriptor.HIGHER_PRIORITY, "4", 1);

    assertMapEquals(patchedUsages, ConvertUsagesUtil.convertString("g3:4=1;g1:3=1;g4:1=1;g2:2=1;"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:StatisticsUploadAssistantTest.java


示例17: testConvertWithTooLongGroupDescriptorId

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
public void testConvertWithTooLongGroupDescriptorId() {
  final Map<GroupDescriptor, Set<PatchedUsage>> patchedUsages = new HashMap<GroupDescriptor, Set<PatchedUsage>>();
  createPatchDescriptor(patchedUsages, "g1", GroupDescriptor.HIGHER_PRIORITY, "k1", 1);
  createPatchDescriptor(patchedUsages, "g1", GroupDescriptor.HIGHER_PRIORITY, "k2", 2);

  final String veryLongGroupId = StringUtil.repeat("g", GroupDescriptor.MAX_ID_LENGTH);
  assertMapEquals(patchedUsages, ConvertUsagesUtil.convertString(veryLongGroupId + ":k1=1;g1:k1=1,k2=2;"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:StatisticsUploadAssistantTest.java


示例18: merge

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
private ParseResult merge(@NotNull ParseResult result) {
  final Map<TextRange, PyType> types = new HashMap<TextRange, PyType>();
  final Map<PyType, TextRange> fullRanges = new HashMap<PyType, TextRange>();
  final Map<PyType, PyImportElement> imports = new HashMap<PyType, PyImportElement>();
  types.putAll(myTypes);
  types.putAll(result.getTypes());
  fullRanges.putAll(myFullRanges);
  fullRanges.putAll(result.getFullRanges());
  imports.putAll(myImports);
  imports.putAll(result.getImports());
  return new ParseResult(myElement, myType, types, fullRanges, imports);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PyTypeParser.java


示例19: processParameters

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
private static void processParameters(@NotNull final Project project,
                                      @NotNull final PyFunction generatedMethod,
                                      @NotNull final AbstractVariableData[] variableData,
                                      final boolean isMethod,
                                      final boolean isClassMethod,
                                      final boolean isStaticMethod) {
  final Map<String, String> map = createMap(variableData);
  // Rename parameters
  for (PyParameter parameter : generatedMethod.getParameterList().getParameters()) {
    final String name = parameter.getName();
    final String newName = map.get(name);
    if (name != null && newName != null && !name.equals(newName)) {
      final Map<PsiElement, String> allRenames = new java.util.HashMap<PsiElement, String>();
      allRenames.put(parameter, newName);
      final UsageInfo[] usages = RenameUtil.findUsages(parameter, newName, false, false, allRenames);
      try {
        RenameUtil.doRename(parameter, newName, usages, project, new RefactoringElementListenerComposite());
      }
      catch (IncorrectOperationException e) {
        RenameUtil.showErrorMessage(e, parameter, project);
        return;
      }
    }
  }
  // Change signature according to pass settings and
  final PyFunctionBuilder builder = new PyFunctionBuilder("foo", generatedMethod);
  if (isClassMethod) {
    builder.parameter("cls");
  }
  else if (isMethod && !isStaticMethod) {
    builder.parameter("self");
  }
  for (AbstractVariableData data : variableData) {
    if (data.isPassAsParameter()) {
      builder.parameter(data.getName());
    }
  }
  final PyParameterList pyParameterList = builder.buildFunction(project, LanguageLevel.forElement(generatedMethod)).getParameterList();
  generatedMethod.getParameterList().replace(pyParameterList);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:PyExtractMethodUtil.java


示例20: createMap

import com.intellij.util.containers.hash.HashMap; //导入依赖的package包/类
@NotNull
private static Map<String, String> createMap(@NotNull final AbstractVariableData[] variableData) {
  final Map<String, String> map = new HashMap<String, String>();
  for (AbstractVariableData data : variableData) {
    map.put(data.getOriginalName(), data.getName());
  }
  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PyExtractMethodUtil.java



注:本文中的com.intellij.util.containers.hash.HashMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IFailureDetector类代码示例发布时间:2022-05-22
下一篇:
Java ORBInitRefResolverImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap