Java Code Examples for gnu.trove.TIntHashSet#contains()
The following examples show how to use
gnu.trove.TIntHashSet#contains() .
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: SATCsimulation.java From jatecs with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("unused") private static IClassificationDB mixClassifications( IClassificationDB trueClassification, IClassificationDB predictedClassification, TIntHashSet fromTrueClassification) { TroveClassificationDBBuilder builder = new TroveClassificationDBBuilder( trueClassification.getDocumentDB(), trueClassification.getCategoryDB()); IIntIterator documents = trueClassification.getDocumentDB() .getDocuments(); while (documents.hasNext()) { int document = documents.next(); if (fromTrueClassification.contains(document)) copyClassification(document, trueClassification, builder); else copyClassification(document, predictedClassification, builder); } return builder.getClassificationDB(); }
Example 2
Source File: Incremental.java From jatecs with GNU General Public License v3.0 | 6 votes |
public Incremental(int trainSize, ClassificationScoreDB classification, TIntHashSet categoriesFilter, EstimationType estimation, ContingencyTableSet evaluation, IGain gain, IGain firstRankGain, double[] probabilitySlope, double[] prevalencies) { super(trainSize, classification, categoriesFilter, estimation, evaluation, firstRankGain, probabilitySlope, prevalencies); macroRankTable = new TIntDoubleHashMap((int) (testSize + testSize * 0.25), (float) 0.75); microRankTable = new TIntDoubleHashMap((int) (testSize + testSize * 0.25), (float) 0.75); macroAlreadySeen = new TIntHashSet((int) (testSize + testSize * 0.25), (float) 0.75); microAlreadySeen = new TIntHashSet((int) (testSize + testSize * 0.25), (float) 0.75); probabilities = new double[testSize][numOfCategories]; for (int docId = 0; docId < testSize; docId++) { Set<Entry<Short, ClassifierRangeWithScore>> entries = classification.getDocumentScoresAsSet(docId); Iterator<Entry<Short, ClassifierRangeWithScore>> iterator = entries.iterator(); while (iterator.hasNext()) { Entry<Short, ClassifierRangeWithScore> next = iterator.next(); ClassifierRangeWithScore value = next.getValue(); if (categoriesFilter.contains(next.getKey())) { probabilities[docId][catMap.get(next.getKey())] = probability(Math.abs(value.score - value.border), next.getKey()); } } } }
Example 3
Source File: TreeNode.java From semafor-semantic-parser with GNU General Public License v3.0 | 6 votes |
/** * * @param alevel Level (depth) of the desired ancestor * @param ancPath A list to be populated with indices of nodes searched (starting with the current node), provided that an ancestor node at the specified level exists; or null. * @param alreadySearched Indices of nodes which have already been searched. If non-null, 'this' will be returned if (and only if) a member of this set is encountered in the ancestor path. * @return Ancestor node of the current node whose level is 'alevel', or null if no such ancestor exists. A node is not considered to be its own ancestor. * @author Nathan Schneider (nschneid) */ @SuppressWarnings("unchecked") public T getAncestorAtLevel(int alevel, TIntArrayList ancPath, TIntHashSet alreadySearched) { if (alevel < 0 || alevel >= this.depth) // A node at this level is not strictly an ancestor return null; TreeNode<T> node = this; for (int d=this.depth; d>alevel; d--) { if (ancPath!=null) ancPath.add(node.index); if (alreadySearched!=null && alreadySearched.contains(node.index)) return (T)this; node = node.getParent(); } return (T)node; }
Example 4
Source File: VirtualDirectoryImpl.java From consulo with Apache License 2.0 | 6 votes |
public void removeChildren(@Nonnull TIntHashSet idsToRemove, @Nonnull List<? extends CharSequence> namesToRemove) { boolean caseSensitive = getFileSystem().isCaseSensitive(); synchronized (myData) { // remove from array by merging two sorted lists int[] newIds = new int[myData.myChildrenIds.length]; int[] oldIds = myData.myChildrenIds; int o = 0; for (int oldId : oldIds) { if (!idsToRemove.contains(oldId)) { newIds[o++] = oldId; } } if (o != newIds.length) { newIds = o == 0 ? ArrayUtilRt.EMPTY_INT_ARRAY : Arrays.copyOf(newIds, o); } myData.myChildrenIds = newIds; if (!allChildrenLoaded()) { myData.addAdoptedNames(namesToRemove, caseSensitive); } assertConsistency(caseSensitive, namesToRemove); } }
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: ClassIDs.java From whyline with MIT License | 5 votes |
public boolean isOrIsSubclassOf(QualifiedClassName name, QualifiedClassName superclass) { if(name == null) return false; if(name == superclass) return true; TIntHashSet subclasses = getSubclassesOf(superclass); return subclasses.contains(name.getID()); }
Example 7
Source File: CacheUtils.java From consulo with Apache License 2.0 | 5 votes |
public static boolean areArraysContentsEqual(int[] exceptions1, int[] exceptions2) { if (exceptions1.length != exceptions2.length) { return false; } if (exceptions1.length != 0) { // optimization TIntHashSet exceptionsSet = new TIntHashSet(exceptions1); for (int exception : exceptions2) { if (!exceptionsSet.contains(exception)) { return false; } } } return true; }
Example 8
Source File: CompactVirtualFileSet.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean contains(Object file) { if (file instanceof VirtualFileWithId) { BitSet ids = fileIds; int id = ((VirtualFileWithId)file).getId(); if (ids != null) { return ids.get(id); } TIntHashSet idSet = this.idSet; if (idSet != null) { return idSet.contains(id); } } return weirdFiles.contains(file); }
Example 9
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 10
Source File: TranslatingCompilerFilesMonitorImpl.java From consulo with Apache License 2.0 | 4 votes |
private boolean isMarkedForRecompilation(int projectId, final int srcId) { synchronized (myDataLock) { final TIntHashSet set = mySourcesToRecompile.get(projectId); return set != null && set.contains(srcId); } }
Example 11
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; }