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


Java HashMap类代码示例

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


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


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