Java Code Examples for gnu.trove.TIntObjectHashMap#get()
The following examples show how to use
gnu.trove.TIntObjectHashMap#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SegmentationScore.java From semafor-semantic-parser with GNU General Public License v3.0 | 6 votes |
public static void getScore(TIntObjectHashMap<Set<String>> goldMap, TIntObjectHashMap<Set<String>> autoMap) { int[] keys = goldMap.keys(); double totalGold = 0.0; double totalAuto = 0.0; double correct = 0.0; for (int i = 0; i < keys.length; i ++) { Set<String> gIdxs = goldMap.get(keys[i]); if (!autoMap.contains(keys[i])) { totalGold += gIdxs.size(); } else { Set<String> aIdxs = autoMap.get(keys[i]); totalGold += gIdxs.size(); totalAuto += aIdxs.size(); for (String a: aIdxs) { if (gIdxs.contains(a)) { correct++; } } } } double precision = (correct/totalAuto); double recall = (correct/totalGold); double f = 2 * (precision * recall) / (precision + recall); System.out.println("P="+precision+" R="+recall+" F="+f); }
Example 2
Source File: Win32FsCache.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull String[] list(@Nonnull VirtualFile file) { String path = file.getPath(); FileInfo[] fileInfo = myKernel.listChildren(path); if (fileInfo == null || fileInfo.length == 0) { return ArrayUtil.EMPTY_STRING_ARRAY; } String[] names = new String[fileInfo.length]; TIntObjectHashMap<THashMap<String, FileAttributes>> map = getMap(); int parentId = ((VirtualFileWithId)file).getId(); THashMap<String, FileAttributes> nestedMap = map.get(parentId); if (nestedMap == null) { nestedMap = new THashMap<String, FileAttributes>(fileInfo.length, FileUtil.PATH_HASHING_STRATEGY); map.put(parentId, nestedMap); } for (int i = 0, length = fileInfo.length; i < length; i++) { FileInfo info = fileInfo[i]; String name = info.getName(); nestedMap.put(name, info.toFileAttributes()); names[i] = name; } return names; }
Example 3
Source File: Win32FsCache.java From consulo with Apache License 2.0 | 6 votes |
@Nullable FileAttributes getAttributes(@Nonnull VirtualFile file) { VirtualFile parent = file.getParent(); int parentId = parent instanceof VirtualFileWithId ? ((VirtualFileWithId)parent).getId() : -((VirtualFileWithId)file).getId(); TIntObjectHashMap<THashMap<String, FileAttributes>> map = getMap(); THashMap<String, FileAttributes> nestedMap = map.get(parentId); String name = file.getName(); FileAttributes attributes = nestedMap != null ? nestedMap.get(name) : null; if (attributes == null) { if (nestedMap != null && !(nestedMap instanceof IncompleteChildrenMap)) { return null; // our info from parent doesn't mention the child in this refresh session } FileInfo info = myKernel.getInfo(file.getPath()); if (info == null) { return null; } attributes = info.toFileAttributes(); if (nestedMap == null) { nestedMap = new IncompleteChildrenMap<>(FileUtil.PATH_HASHING_STRATEGY); map.put(parentId, nestedMap); } nestedMap.put(name, attributes); } return attributes; }
Example 4
Source File: DuplicatesProfileCache.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static DuplicatesProfile getProfile(@Nonnull DupInfo dupInfo, int index) { TIntObjectHashMap<DuplicatesProfile> patternCache = ourProfileCache.get(dupInfo); if (patternCache == null) { patternCache = new TIntObjectHashMap<>(); ourProfileCache.put(dupInfo, patternCache); } DuplicatesProfile result = patternCache.get(index); if (result == null) { DuplicatesProfile theProfile = null; for (DuplicatesProfile profile : DuplicatesProfile.EP_NAME.getExtensionList()) { if (profile.isMyDuplicate(dupInfo, index)) { theProfile = profile; break; } } result = theProfile == null ? NULL_PROFILE : theProfile; patternCache.put(index, result); } return result == NULL_PROFILE ? null : result; }
Example 5
Source File: FlutterWidgetPerf.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private FilePerfInfo buildSummaryStats(TextEditor fileEditor) { final String path = fileEditor.getFile().getPath(); final FilePerfInfo fileStats = new FilePerfInfo(); for (PerfReportKind kind : PerfReportKind.values()) { final StatsForReportKind forKind = stats.get(kind); if (forKind == null) { continue; } final TIntObjectHashMap<SlidingWindowStats> data = forKind.data; for (Location location : locationsPerFile.get(path)) { final SlidingWindowStats entry = data.get(location.id); if (entry == null) { continue; } final TextRange range = location.textRange; if (range == null) { continue; } fileStats.add( range, new SummaryStats( kind, new SlidingWindowStatsSummary(entry, forKind.lastStartTime, location), location.name ) ); } } return fileStats; }
Example 6
Source File: FlutterWidgetPerf.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private FilePerfInfo buildSummaryStats(TextEditor fileEditor) { final String path = fileEditor.getFile().getPath(); final FilePerfInfo fileStats = new FilePerfInfo(); for (PerfReportKind kind : PerfReportKind.values()) { final StatsForReportKind forKind = stats.get(kind); if (forKind == null) { continue; } final TIntObjectHashMap<SlidingWindowStats> data = forKind.data; for (Location location : locationsPerFile.get(path)) { final SlidingWindowStats entry = data.get(location.id); if (entry == null) { continue; } final TextRange range = location.textRange; if (range == null) { continue; } fileStats.add( range, new SummaryStats( kind, new SlidingWindowStatsSummary(entry, forKind.lastStartTime, location), location.name ) ); } } return fileStats; }
Example 7
Source File: ExpandedSupModel.java From semafor-semantic-parser with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) { String supmodel = args[0]; String supalphabet = args[1]; String ssalphabet = args[2]; String outmodel = args[3]; TIntObjectHashMap<String> supAlphabet = readAlphabet(supalphabet); TObjectIntHashMap<String> rSupAlphabet = getReverseMap(supAlphabet); TIntObjectHashMap<String> ssAlphabet = readAlphabet(ssalphabet); int supsize = supAlphabet.size(); int sssize = ssAlphabet.size(); double[] supmodelarr = readDoubleArray(supmodel, supsize+1); double[] ssmodelarr = new double[sssize+1]; ssmodelarr[0] = supmodelarr[0]; for (int i = 1; i < sssize+1; i++) { String feat = ssAlphabet.get(i); if (rSupAlphabet.contains(feat)) { int index = rSupAlphabet.get(feat); ssmodelarr[i] = supmodelarr[index]; } else { ssmodelarr[i] = 1.0; } } writeArray(ssmodelarr, outmodel); }
Example 8
Source File: LinesUtil.java From consulo with Apache License 2.0 | 5 votes |
public static LineData[] calcLineArray(final int maxLineNumber, final TIntObjectHashMap lines) { final LineData[] linesArray = new LineData[maxLineNumber + 1]; for(int line = 1; line <= maxLineNumber; line++) { final LineData lineData = (LineData) lines.get(line); if (lineData != null) { lineData.fillArrays(); } linesArray[line] = lineData; } return linesArray; }
Example 9
Source File: ParameterHintsPassFactory.java From consulo with Apache License 2.0 | 5 votes |
private boolean delayRemoval(Inlay inlay, TIntObjectHashMap<Caret> caretMap) { int offset = inlay.getOffset(); Caret caret = caretMap.get(offset); if (caret == null) return false; char afterCaret = myEditor.getDocument().getImmutableCharSequence().charAt(offset); if (afterCaret != ',' && afterCaret != ')') return false; VisualPosition afterInlayPosition = myEditor.offsetToVisualPosition(offset, true, false); // check whether caret is to the right of inlay if (!caret.getVisualPosition().equals(afterInlayPosition)) return false; return true; }
Example 10
Source File: LineMarkersPass.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static List<LineMarkerInfo<PsiElement>> mergeLineMarkers(@Nonnull List<LineMarkerInfo<PsiElement>> markers, @Nonnull Document document) { List<MergeableLineMarkerInfo<PsiElement>> forMerge = new ArrayList<>(); TIntObjectHashMap<List<MergeableLineMarkerInfo<PsiElement>>> sameLineMarkers = new TIntObjectHashMap<>(); for (int i = markers.size() - 1; i >= 0; i--) { LineMarkerInfo<PsiElement> marker = markers.get(i); if (marker instanceof MergeableLineMarkerInfo) { MergeableLineMarkerInfo<PsiElement> mergeable = (MergeableLineMarkerInfo<PsiElement>)marker; forMerge.add(mergeable); markers.remove(i); int line = document.getLineNumber(marker.startOffset); List<MergeableLineMarkerInfo<PsiElement>> infos = sameLineMarkers.get(line); if (infos == null) { infos = new ArrayList<>(); sameLineMarkers.put(line, infos); } infos.add(mergeable); } } if (forMerge.isEmpty()) return markers; List<LineMarkerInfo<PsiElement>> result = new ArrayList<>(markers); sameLineMarkers.forEachValue(infos -> result.addAll(MergeableLineMarkerInfo.merge(infos))); return result; }
Example 11
Source File: HighlightCommand.java From CppTools with Apache License 2.0 | 5 votes |
private static RangeHighlighter processHighlighter(int hFrom, int hTo, int colorIndex, TextAttributes attrs, Editor editor, TIntObjectHashMap<RangeHighlighter> lastOffsetToMarkersMap, THashSet<RangeHighlighter> highlightersSet, THashSet<RangeHighlighter> invalidMarkersSet ) { RangeHighlighter rangeHighlighter = lastOffsetToMarkersMap.get(hFrom); if (rangeHighlighter == null || rangeHighlighter.getEndOffset() != hTo || rangeHighlighter.getTextAttributes() != attrs ) { highlightersSet.add( rangeHighlighter = HighlightUtils.createRangeMarker( editor, hFrom, hTo, colorIndex, attrs ) ); lastOffsetToMarkersMap.put(hFrom, rangeHighlighter); } else { highlightersSet.add(rangeHighlighter); invalidMarkersSet.remove(rangeHighlighter); } return rangeHighlighter; }
Example 12
Source File: CompressedRefs.java From consulo with Apache License 2.0 | 4 votes |
private static void putRef(@Nonnull TIntObjectHashMap<List<VcsRef>> map, @Nonnull VcsRef ref, @Nonnull VcsLogStorage hashMap) { int index = hashMap.getCommitIndex(ref.getCommitHash(), ref.getRoot()); List<VcsRef> list = map.get(index); if (list == null) map.put(index, list = new SmartList<>()); list.add(ref); }
Example 13
Source File: CompressedRefs.java From consulo with Apache License 2.0 | 4 votes |
private static void putRefIndex(@Nonnull TIntObjectHashMap<TIntArrayList> map, @Nonnull VcsRef ref, @Nonnull VcsLogStorage hashMap) { int index = hashMap.getCommitIndex(ref.getCommitHash(), ref.getRoot()); TIntArrayList list = map.get(index); if (list == null) map.put(index, list = new TIntArrayList()); list.add(hashMap.getRefIndex(ref)); }
Example 14
Source File: LocalDependencies.java From whyline with MIT License | 2 votes |
public List<SetLocal> getPotentialDefinitionsOfLocalIDBefore(Instruction instruction, int localID) { TIntObjectHashMap<List<SetLocal>> definitionsByInstruction = definitionsByInstructionIndexLocalID.get(localID); if(definitionsByInstruction == null) { definitionsByInstruction = new TIntObjectHashMap<List<SetLocal>>(4); definitionsByInstructionIndexLocalID.put(localID, definitionsByInstruction); } List<SetLocal> potentialDefs = definitionsByInstruction.get(instruction.getIndex()); if(potentialDefs == null) { potentialDefs = new LinkedList<SetLocal>(); definitionsByInstruction.put(instruction.getIndex(), potentialDefs); gnu.trove.TIntHashSet visited = new gnu.trove.TIntHashSet(64); Vector<Instruction> instructionsToAnalyze = new Vector<Instruction>(3); instructionsToAnalyze.add(instruction); while(!instructionsToAnalyze.isEmpty()) { Instruction instructionToAnalyze = instructionsToAnalyze.remove(instructionsToAnalyze.size() - 1); if(!visited.contains(instructionToAnalyze.getIndex())) { visited.add(instructionToAnalyze.getIndex()); for(Instruction predecessor : instructionToAnalyze.getOrderedPredecessors()) if(predecessor instanceof SetLocal && ((SetLocal)predecessor).getLocalID() == localID) potentialDefs.add((SetLocal)predecessor); else instructionsToAnalyze.add(predecessor); } } } return potentialDefs; }