Java Code Examples for gnu.trove.TIntHashSet#add()
The following examples show how to use
gnu.trove.TIntHashSet#add() .
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: VcsLogGraphTable.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private Pair<TIntHashSet, Integer> findRowsToSelectAndScroll(@Nonnull GraphTableModel model, @Nonnull VisibleGraph<Integer> visibleGraph) { TIntHashSet rowsToSelect = new TIntHashSet(); if (model.getRowCount() == 0) { // this should have been covered by facade.getVisibleCommitCount, // but if the table is empty (no commits match the filter), the GraphFacade is not updated, because it can't handle it // => it has previous values set. return Pair.create(rowsToSelect, null); } Integer rowToScroll = null; for (int row = 0; row < visibleGraph.getVisibleCommitCount() && (rowsToSelect.size() < mySelectedCommits.size() || rowToScroll == null); row++) { //stop iterating if found all hashes int commit = visibleGraph.getRowInfo(row).getCommit(); if (mySelectedCommits.contains(commit)) { rowsToSelect.add(row); } if (myVisibleSelectedCommit != null && myVisibleSelectedCommit == commit) { rowToScroll = row; } } return Pair.create(rowsToSelect, rowToScroll); }
Example 2
Source File: XLineBreakpointManager.java From consulo with Apache License 2.0 | 6 votes |
private void updateBreakpoints(@Nonnull Document document) { Collection<XLineBreakpointImpl> breakpoints = myBreakpoints.getKeysByValue(document); if (breakpoints == null) { return; } TIntHashSet lines = new TIntHashSet(); List<XBreakpoint<?>> toRemove = new SmartList<>(); for (XLineBreakpointImpl breakpoint : breakpoints) { breakpoint.updatePosition(); if (!breakpoint.isValid() || !lines.add(breakpoint.getLine())) { toRemove.add(breakpoint); } } removeBreakpoints(toRemove); }
Example 3
Source File: ContributorsBasedGotoByModel.java From consulo with Apache License 2.0 | 6 votes |
public void processContributorNames(@Nonnull ChooseByNameContributor contributor, @Nonnull FindSymbolParameters parameters, @Nonnull Processor<? super String> nameProcessor) { TIntHashSet filter = new TIntHashSet(1000); if (contributor instanceof ChooseByNameContributorEx) { ((ChooseByNameContributorEx)contributor).processNames(s -> { if (nameProcessor.process(s)) { filter.add(s.hashCode()); } return true; }, parameters.getSearchScope(), parameters.getIdFilter()); } else { String[] names = contributor.getNames(myProject, parameters.isSearchInLibraries()); for (String element : names) { if (nameProcessor.process(element)) { filter.add(element.hashCode()); } } } myContributorToItsSymbolsMap.put(contributor, filter); }
Example 4
Source File: Classfile.java From whyline with MIT License | 5 votes |
/** * Creates a cached table of superclass name IDs. */ private void determineSuperclasses() { superclasses = new TIntHashSet(2); Classfile clazz = this; while(clazz != null) { ClassInfo superInfo = clazz.getSuperclassInfo(); if(superInfo != null) superclasses.add(superInfo.getName().getID()); clazz = clazz.getSuperclass(); } superclasses.trimToSize(); }
Example 5
Source File: ControlDependencies.java From whyline with MIT License | 5 votes |
private TObjectIntHashMap<Instruction> visitPostOrderIterative(Instruction start, ArrayList<Instruction> instructionsInPostOrderTraversalOfReverseControlFlowGraph) { TObjectIntHashMap<Instruction>postOrderNumbers = new TObjectIntHashMap<Instruction>(); ArrayList<Instruction> stack = new ArrayList<Instruction>(); TIntHashSet visitedIndices = new TIntHashSet(code.getNumberOfInstructions()); TIntHashSet processedIndices = new TIntHashSet(code.getNumberOfInstructions()); stack.add(start); while(stack.size() > 0) { Instruction top = stack.get(stack.size() - 1); if(visitedIndices.contains(top.getIndex())) { stack.remove(stack.size() - 1); if(!processedIndices.contains(top.getIndex())) { processedIndices.add(top.getIndex()); instructionsInPostOrderTraversalOfReverseControlFlowGraph.add(0, top); postOrderNumbers.put(top, instructionsInPostOrderTraversalOfReverseControlFlowGraph.size()); } } // Remember that we were here, then add the predecessors in reverse order to the stack. else { visitedIndices.add(top.getIndex()); int insertionIndex = 0; for(Instruction predecessor : top.getOrderedPredecessors()) { if(!visitedIndices.contains(predecessor.getIndex())) { stack.add(stack.size() - insertionIndex, predecessor); insertionIndex++; } } } } return postOrderNumbers; }
Example 6
Source File: CSharpFilePropertyPusher.java From consulo-csharp with Apache License 2.0 | 5 votes |
private static int varHashCode(@Nonnull Collection<String> vars) { Set<String> sortedSet = new TreeSet<>(vars); TIntHashSet intSet = new TIntHashSet(); for(String varName : sortedSet) { intSet.add(varName.hashCode()); } return intSet.hashCode(); }
Example 7
Source File: SoftWrapApplianceOnDocumentModificationTest.java From consulo with Apache License 2.0 | 5 votes |
private static TIntHashSet collectSoftWrapStartOffsets(int documentLine) { TIntHashSet result = new TIntHashSet(); for (SoftWrap softWrap : myEditor.getSoftWrapModel().getSoftWrapsForLine(documentLine)) { result.add(softWrap.getStart()); } return result; }
Example 8
Source File: AbstractDataGetter.java From consulo with Apache License 2.0 | 5 votes |
private void runLoadCommitsData(@Nonnull Iterable<Integer> hashes) { long taskNumber = myCurrentTaskIndex++; TIntIntHashMap commits = getCommitsMap(hashes); TIntHashSet toLoad = new TIntHashSet(); for (int id : commits.keys()) { cacheCommit(id, taskNumber); toLoad.add(id); } myLoader.queue(new TaskDescriptor(toLoad)); }
Example 9
Source File: VcsLogGraphTable.java From consulo with Apache License 2.0 | 5 votes |
public Selection(@Nonnull VcsLogGraphTable table) { myTable = table; List<Integer> selectedRows = ContainerUtil.sorted(Ints.asList(myTable.getSelectedRows())); Couple<Integer> visibleRows = ScrollingUtil.getVisibleRows(myTable); myIsOnTop = visibleRows.first - 1 == 0; VisibleGraph<Integer> graph = myTable.getVisibleGraph(); mySelectedCommits = new TIntHashSet(); Integer visibleSelectedCommit = null; Integer delta = null; for (int row : selectedRows) { if (row < graph.getVisibleCommitCount()) { Integer commit = graph.getRowInfo(row).getCommit(); mySelectedCommits.add(commit); if (visibleRows.first - 1 <= row && row <= visibleRows.second && visibleSelectedCommit == null) { visibleSelectedCommit = commit; delta = myTable.getCellRect(row, 0, false).y - myTable.getVisibleRect().y; } } } if (visibleSelectedCommit == null && visibleRows.first - 1 >= 0) { visibleSelectedCommit = graph.getRowInfo(visibleRows.first - 1).getCommit(); delta = myTable.getCellRect(visibleRows.first - 1, 0, false).y - myTable.getVisibleRect().y; } myVisibleSelectedCommit = visibleSelectedCommit; myDelta = delta; }
Example 10
Source File: PersistentFSImpl.java From consulo with Apache License 2.0 | 5 votes |
private void applyDeletions(@Nonnull MultiMap<VirtualDirectoryImpl, VFileDeleteEvent> deletions) { for (Map.Entry<VirtualDirectoryImpl, Collection<VFileDeleteEvent>> entry : deletions.entrySet()) { VirtualDirectoryImpl parent = entry.getKey(); Collection<VFileDeleteEvent> deleteEvents = entry.getValue(); // no valid containing directory, apply events the old way - one by one if (parent == null || !parent.isValid()) { deleteEvents.forEach(this::applyEvent); return; } int parentId = getFileId(parent); int[] oldIds = FSRecords.list(parentId); TIntHashSet parentChildrenIds = new TIntHashSet(oldIds); List<CharSequence> childrenNamesDeleted = new ArrayList<>(deleteEvents.size()); TIntHashSet childrenIdsDeleted = new TIntHashSet(deleteEvents.size()); for (VFileDeleteEvent event : deleteEvents) { VirtualFile file = event.getFile(); int id = getFileId(file); childrenNamesDeleted.add(file.getNameSequence()); childrenIdsDeleted.add(id); FSRecords.deleteRecordRecursively(id); invalidateSubtree(file); parentChildrenIds.remove(id); } FSRecords.updateList(parentId, parentChildrenIds.toArray()); parent.removeChildren(childrenIdsDeleted, childrenNamesDeleted); } }
Example 11
Source File: VfsAwareMapIndexStorage.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static TIntHashSet loadHashedIds(@Nonnull File fileWithCaches) throws IOException { try (DataInputStream inputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(fileWithCaches)))) { int capacity = DataInputOutputUtil.readINT(inputStream); TIntHashSet hashMaskSet = new TIntHashSet(capacity); while (capacity > 0) { hashMaskSet.add(DataInputOutputUtil.readINT(inputStream)); --capacity; } return hashMaskSet; } }
Example 12
Source File: Reliability.java From jatecs with GNU General Public License v3.0 | 4 votes |
public Reliability(ClassificationScoreDB predConfidences, IClassificationDB trueClassification, double[] probabilitySlopes, TIntHashSet categoriesFilter) { this.slopes = probabilitySlopes; IShortIterator catsIter = trueClassification.getCategoryDB() .getCategories(); IIntIterator docsIter = trueClassification.getDocumentDB() .getDocuments(); double f1 = 0.0; // double TP = 0.0; // double FP = 0.0; // double FN = 0.0; // double TN = 0.0; while (catsIter.hasNext()) { short catId = catsIter.next(); if (!categoriesFilter.contains(catId)) { continue; } double tp = 0.0; double fp = 0.0; double fn = 0.0; // double tn = 0.0; // double gpos = 0.0; // double score = 0.0; IIntIterator trueDocsIter = trueClassification .getCategoryDocuments(catId); TIntHashSet trueDocs = new TIntHashSet(); while (trueDocsIter.hasNext()) { trueDocs.add(trueDocsIter.next()); // gpos++; } docsIter.begin(); while (docsIter.hasNext()) { int docId = docsIter.next(); Hashtable<Short, ClassifierRangeWithScore> catConfidences = predConfidences .getDocumentScoresAsHashtable(docId); ClassifierRangeWithScore value = catConfidences.get(catId); // double predLabel = probability(Math.abs(value.score - // value.border), catId); double predLabel = scaleConfidence(value.score - value.border, catId); // if ((value.score - value.border) <= 0.0) predLabel = // -predLabel; // System.out.println(value.score - value.border); if (trueDocs.contains(docId)) { tp += predLabel; fn += 1.0 - predLabel; // //score += value.score - value.border; // if ((value.score - value.border) > 0.0) { // tp += predLabel; // //System.out.println(docId + " " + catId + " tp " + // predLabel); // // } else { // fn += 1.0 - predLabel; // //System.out.println(docId + " " + catId + " fn " + // predLabel); // } // } else { // if ((value.score - value.border) > 0.0) { // fp += predLabel; // //System.out.println(docId + " " + catId + " fp " + // predLabel); // } else { // tn += 1.0 - predLabel; // //System.out.println(docId + " " + catId + " tn " + // predLabel); // } } else { fp += predLabel; } } // System.out.println(catId + " " + gpos + " " + score + " " + tp + // " " + fp + " " + fn) // to do precision and recall double den = (2.0 * tp) + fn + fp; // TP += tp; // FP += fp; // FN += fn; // TN += tn; if (den != 0) { f1 += (2 * tp) / den; } else { f1 += 1.0; } } // System.out.println(this.reliability); this.reliability = f1 / trueClassification.getCategoryDB().getCategoriesCount(); // System.out.println(this.reliability); // System.out.println(TP + " " + FP + " " + FN + " " + TN + " " + (new // F(1.0).get(TP, 0.0, FP, FN))); }
Example 13
Source File: ChangeListStorageImpl.java From consulo with Apache License 2.0 | 4 votes |
private int doReadPrevSafely(int id, TIntHashSet recursionGuard) throws IOException { recursionGuard.add(id); int prev = myStorage.getPrevRecord(id); if (!recursionGuard.add(prev)) throw new IOException("Recursive records found"); return prev; }
Example 14
Source File: ParametersListUtil.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public static List<String> parse(@Nonnull String parameterString, boolean keepQuotes, boolean supportSingleQuotes, boolean keepEmptyParameters) { if (!keepEmptyParameters) { parameterString = parameterString.trim(); } final ArrayList<String> params = new ArrayList<>(); if (parameterString.isEmpty()) { return params; } final StringBuilder token = new StringBuilder(128); boolean inQuotes = false; boolean escapedQuote = false; final TIntHashSet possibleQuoteChars = new TIntHashSet(); possibleQuoteChars.add('"'); if (supportSingleQuotes) { possibleQuoteChars.add('\''); } char currentQuote = 0; boolean nonEmpty = false; for (int i = 0; i < parameterString.length(); i++) { final char ch = parameterString.charAt(i); if ((inQuotes ? currentQuote == ch : possibleQuoteChars.contains(ch))) { if (!escapedQuote) { inQuotes = !inQuotes; currentQuote = ch; nonEmpty = true; if (!keepQuotes) { continue; } } escapedQuote = false; } else if (Character.isWhitespace(ch)) { if (!inQuotes) { if (keepEmptyParameters || token.length() > 0 || nonEmpty) { params.add(token.toString()); token.setLength(0); nonEmpty = false; } continue; } } else if (ch == '\\' && i < parameterString.length() - 1) { final char nextchar = parameterString.charAt(i + 1); if (inQuotes ? currentQuote == nextchar : possibleQuoteChars.contains(nextchar)) { escapedQuote = true; if (!keepQuotes) { continue; } } } token.append(ch); } if (keepEmptyParameters || token.length() > 0 || nonEmpty) { params.add(token.toString()); } return params; }
Example 15
Source File: ClassIDs.java From whyline with MIT License | 2 votes |
/** * Given a path to search for the id file, loads the mappings from the file if found * * @param classIDsFile * @throws Exception */ public ClassIDs(File classIDsFile) throws IOException { // Load the class ids file for this trace. this.classIDFile = classIDsFile; BufferedReader reader = null; if(classIDFile.isFile()) { reader = new BufferedReader(new FileReader(classIDFile)); if(classIDFile.length() > 0) { while(true) { String entry = reader.readLine(); if(entry == null) break; ClassID id = new ClassID(entry); if(classesByID.containsKey(id.id)) throw new RuntimeException("This classid cache is corrupt! " + classesByID.get(id.id) + " is already assigned id " + id); classesByName.put(id.name, id); classesByID.put(id.id, id); if(id.id > nextClassID) nextClassID = id.id; } nextClassID++; } reader.close(); } else throw new IOException("Couldn't find file " + classIDsFile); subclassesOfTextualOutputProducers = new TIntHashSet(); subclassesOfTextualOutputProducers.add(QualifiedClassName.STRING_BUILDER.getID()); subclassesOfTextualOutputProducers.addAll(getSubclassesOf(QualifiedClassName.STRING_BUILDER).toArray()); subclassesOfTextualOutputProducers.add(QualifiedClassName.OUTPUT_STREAM.getID()); subclassesOfTextualOutputProducers.addAll(getSubclassesOf(QualifiedClassName.OUTPUT_STREAM).toArray()); subclassesOfTextualOutputProducers.add(QualifiedClassName.WRITER.getID()); subclassesOfTextualOutputProducers.addAll(getSubclassesOf(QualifiedClassName.WRITER).toArray()); }