Java Code Examples for gnu.trove.TIntIntHashMap#put()
The following examples show how to use
gnu.trove.TIntIntHashMap#put() .
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: BlazeCoverageData.java From intellij with Apache License 2.0 | 6 votes |
private static TIntIntHashMap parseHits(BufferedReader reader) throws IOException { TIntIntHashMap hits = new TIntIntHashMap(); String line; while ((line = reader.readLine()) != null) { if (line.startsWith(END_OF_RECORD)) { return hits; } if (line.startsWith(DA)) { // DA:line,hits int comma = line.indexOf(','); try { hits.put( Integer.parseInt(line.substring(DA.length(), comma)), Integer.parseInt(line.substring(comma + 1))); } catch (NumberFormatException e) { logger.warn("Cannot parse LCOV line: " + line, e); } } } return hits; }
Example 2
Source File: SrcFileAnnotator.java From consulo with Apache License 2.0 | 6 votes |
private static TIntIntHashMap getCoverageVersionToCurrentLineMapping(Diff.Change change, int firstNLines) { TIntIntHashMap result = new TIntIntHashMap(); int prevLineInFirst = 0; int prevLineInSecond = 0; while (change != null) { for (int l = 0; l < change.line0 - prevLineInFirst; l++) { result.put(prevLineInFirst + l, prevLineInSecond + l); } prevLineInFirst = change.line0 + change.deleted; prevLineInSecond = change.line1 + change.inserted; change = change.link; } for (int i = prevLineInFirst; i < firstNLines; i++) { result.put(i, prevLineInSecond + i - prevLineInFirst); } return result; }
Example 3
Source File: IntToIntBtree.java From consulo with Apache License 2.0 | 6 votes |
HashLeafData(BtreeIndexNodeView _nodeView, int recordCount) { nodeView = _nodeView; final IntToIntBtree btree = _nodeView.btree; int offset = nodeView.myAddressInBuffer + nodeView.indexToOffset(0); final ByteBuffer buffer = nodeView.myBuffer; keys = new int[recordCount]; values = new TIntIntHashMap(recordCount); int keyNumber = 0; for (int i = 0; i < btree.hashPageCapacity; ++i) { int key = buffer.getInt(offset + KEY_OFFSET); if (key != HASH_FREE) { int value = buffer.getInt(offset); if (keyNumber == keys.length) throw new IllegalStateException("Index corrupted"); keys[keyNumber++] = key; values.put(key, value); } offset += INTERIOR_SIZE; } Arrays.sort(keys); }
Example 4
Source File: NameSuggester.java From consulo with Apache License 2.0 | 6 votes |
private TIntIntHashMap calculateMatches(final String[] propertyWords) { int classNameIndex = myOldClassName.length - 1; TIntIntHashMap matches = new TIntIntHashMap(); for (int i = propertyWords.length - 1; i >= 0; i--) { final String propertyWord = propertyWords[i]; Match match = null; for (int j = classNameIndex; j >= 0 && match == null; j--) { match = checkMatch(j, i, propertyWord); } if (match != null) { matches.put(match.oldClassNameIndex, i); classNameIndex = match.oldClassNameIndex - 1; } } return matches; }
Example 5
Source File: Util.java From whyline with MIT License | 5 votes |
public static void readIntIntMap(DataInputStream stream, TIntIntHashMap map) throws IOException { int size = stream.readInt(); map.ensureCapacity(size); for(int i = 0; i < size; i++) map.put(stream.readInt(), stream.readInt()); }
Example 6
Source File: TroveDocumentsDB.java From jatecs with GNU General Public License v3.0 | 5 votes |
public void removeDocuments(IIntIterator removedDocuments) { int shift = 0; int lastGoodDocument = 0; int totalDocuments = _documentsMap.size(); TIntIntHashMap documentsRemap = new TIntIntHashMap(); while (removedDocuments.hasNext()) { int removedDocument = removedDocuments.next(); while (lastGoodDocument < removedDocument) { documentsRemap.put(lastGoodDocument, lastGoodDocument - shift); ++lastGoodDocument; } lastGoodDocument = removedDocument + 1; int removedDocumentPosition = removedDocument - shift; _documentsMap.remove(_documentsRMap.get(removedDocumentPosition)); _documentsRMap.remove(removedDocumentPosition); ++shift; } while (lastGoodDocument < totalDocuments) { documentsRemap.put(lastGoodDocument, lastGoodDocument - shift); ++lastGoodDocument; } Iterator<Entry<String, Integer>> mapIter = _documentsMap.entrySet() .iterator(); while (mapIter.hasNext()) { Entry<String, Integer> entry = mapIter.next(); int value = entry.getValue(); int newvalue = documentsRemap.get(value); entry.setValue(newvalue); } }
Example 7
Source File: TroveFeaturesDB.java From jatecs with GNU General Public License v3.0 | 5 votes |
public void removeFeatures(IIntIterator removedFeatures) { int shift = 0; int lastGoodFeature = 0; int totalFeatures = _featuresMap.size(); TIntIntHashMap featuresRemap = new TIntIntHashMap(); while (removedFeatures.hasNext()) { int removedFeature = removedFeatures.next(); while (lastGoodFeature < removedFeature) { featuresRemap.put(lastGoodFeature, lastGoodFeature - shift); ++lastGoodFeature; } lastGoodFeature = removedFeature + 1; int removedFeaturePosition = removedFeature - shift; _featuresMap.remove(_featuresRMap.get(removedFeaturePosition)); _featuresRMap.remove(removedFeaturePosition); ++shift; } while (lastGoodFeature < totalFeatures) { featuresRemap.put(lastGoodFeature, lastGoodFeature - shift); ++lastGoodFeature; } TObjectIntIterator<String> mapIter = _featuresMap.iterator(); while (mapIter.hasNext()) { mapIter.advance(); int value = mapIter.value(); int newvalue = featuresRemap.get(value); mapIter.setValue(newvalue); } }
Example 8
Source File: AbstractDataGetter.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static TIntIntHashMap getCommitsMap(@Nonnull Iterable<Integer> hashes) { TIntIntHashMap commits = new TIntIntHashMap(); int row = 0; for (Integer commitId : hashes) { commits.put(commitId, row); row++; } return commits; }
Example 9
Source File: DeleteToWordStartAction.java From consulo with Apache License 2.0 | 5 votes |
private static void countQuotes(@Nonnull TIntIntHashMap holder, @Nonnull CharSequence text, int start, int end) { for (int i = end - 1; i >= start; i--) { char c = text.charAt(i); if (holder.containsKey(c)) { holder.put(c, holder.get(c) + 1); } } }
Example 10
Source File: TracingData.java From consulo with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws IOException { PersistentHashMap<Integer, Integer> lkeys = createOrOpenMap(); List<Integer> mapping = (List<Integer>)lkeys.getAllKeysWithExistingMapping(); System.out.println(mapping.size()); final TIntIntHashMap map = new TIntIntHashMap(mapping.size()); for(Integer i:mapping) map.put(i, lkeys.get(i)); Collections.sort(mapping, (o1, o2) -> map.get(o2) - map.get(o1)); for(int i = 0; i < 500; ++i) { //System.out.println(mapping.get(i) + ","); System.out.println(mapping.get(i) + ":" + map.get(mapping.get(i))); } lkeys.close(); }
Example 11
Source File: DCSSingleLabelKnnFoldValidator.java From jatecs with GNU General Public License v3.0 | 4 votes |
public static Pair<IIndex, IIndex> splitIndex(int step, IIndex index, int numValidationSteps) { int numPositives = index.getDocumentDB().getDocumentsCount(); int numSteps = Math.min(numPositives, numValidationSteps); if (step >= numSteps) return null; TIntArrayList tr = new TIntArrayList(); TIntArrayList va = new TIntArrayList(); int numPositivesInValidation = numPositives / numSteps; int numPositivesInTraining = numPositives - numPositivesInValidation; int startTrainingID = (numPositives / numSteps) * step; int endTrainingID = (startTrainingID + numPositivesInTraining - 1); TIntIntHashMap map = new TIntIntHashMap(); for (int i = startTrainingID; i <= endTrainingID; i++) { int v = i % numPositives; map.put(v, v); } int curDoc = 0; IIntIterator docs = index.getDocumentDB().getDocuments(); while (docs.hasNext()) { int docID = docs.next(); if (map.containsKey(curDoc)) { tr.add(docID); } else { va.add(docID); } curDoc++; } tr.sort(); va.sort(); IIndex trIndex = index.cloneIndex(); trIndex.removeDocuments(new TIntArrayListIterator(va), false); IIndex vaIndex = index.cloneIndex(); vaIndex.removeDocuments(new TIntArrayListIterator(tr), false); JatecsLogger.status().println( "done. The training contains " + tr.size() + " document(s) and the validation contains " + va.size() + " document(s)."); Pair<IIndex, IIndex> ret = new Pair<IIndex, IIndex>(trIndex, vaIndex); return ret; }
Example 12
Source File: CRWMVSingleLabelKnnFoldValidator.java From jatecs with GNU General Public License v3.0 | 4 votes |
public static Pair<IIndex, IIndex> splitIndex(int step, IIndex index, int numValidationSteps) { int numPositives = index.getDocumentDB().getDocumentsCount(); int numSteps = Math.min(numPositives, numValidationSteps); if (step >= numSteps) return null; TIntArrayList tr = new TIntArrayList(); TIntArrayList va = new TIntArrayList(); int numPositivesInValidation = numPositives / numSteps; int numPositivesInTraining = numPositives - numPositivesInValidation; int startTrainingID = (numPositives / numSteps) * step; int endTrainingID = (startTrainingID + numPositivesInTraining - 1); TIntIntHashMap map = new TIntIntHashMap(); for (int i = startTrainingID; i <= endTrainingID; i++) { int v = i % numPositives; map.put(v, v); } int curDoc = 0; IIntIterator docs = index.getDocumentDB().getDocuments(); while (docs.hasNext()) { int docID = docs.next(); if (map.containsKey(curDoc)) { tr.add(docID); } else { va.add(docID); } curDoc++; } tr.sort(); va.sort(); IIndex trIndex = index.cloneIndex(); trIndex.removeDocuments(new TIntArrayListIterator(va), false); IIndex vaIndex = index.cloneIndex(); vaIndex.removeDocuments(new TIntArrayListIterator(tr), false); JatecsLogger.status().println( "done. The training contains " + tr.size() + " document(s) and the validation contains " + va.size() + " document(s)."); Pair<IIndex, IIndex> ret = new Pair<IIndex, IIndex>(trIndex, vaIndex); return ret; }
Example 13
Source File: SingleLabelKnnFoldValidator.java From jatecs with GNU General Public License v3.0 | 4 votes |
public static Pair<IIndex, IIndex> splitIndex(int step, IIndex index, int numValidationSteps) { int numPositives = index.getDocumentDB().getDocumentsCount(); int numSteps = Math.min(numPositives, numValidationSteps); if (step >= numSteps) return null; TIntArrayList tr = new TIntArrayList(); TIntArrayList va = new TIntArrayList(); int numPositivesInValidation = numPositives / numSteps; int numPositivesInTraining = numPositives - numPositivesInValidation; int startTrainingID = (numPositives / numSteps) * step; int endTrainingID = (startTrainingID + numPositivesInTraining - 1); TIntIntHashMap map = new TIntIntHashMap(); for (int i = startTrainingID; i <= endTrainingID; i++) { int v = i % numPositives; map.put(v, v); } int curDoc = 0; IIntIterator docs = index.getDocumentDB().getDocuments(); while (docs.hasNext()) { int docID = docs.next(); if (map.containsKey(curDoc)) { tr.add(docID); } else { va.add(docID); } curDoc++; } tr.sort(); va.sort(); IIndex trIndex = index.cloneIndex(); trIndex.removeDocuments(new TIntArrayListIterator(va), false); IIndex vaIndex = index.cloneIndex(); vaIndex.removeDocuments(new TIntArrayListIterator(tr), false); JatecsLogger.status().println( "done. The training contains " + tr.size() + " document(s) and the validation contains " + va.size() + " document(s)."); Pair<IIndex, IIndex> ret = new Pair<IIndex, IIndex>(trIndex, vaIndex); return ret; }
Example 14
Source File: WMVSingleLabelKnnFoldValidator.java From jatecs with GNU General Public License v3.0 | 4 votes |
public static Pair<IIndex, IIndex> splitIndex(int step, IIndex index, int numValidationSteps) { int numPositives = index.getDocumentDB().getDocumentsCount(); int numSteps = Math.min(numPositives, numValidationSteps); if (step >= numSteps) return null; TIntArrayList tr = new TIntArrayList(); TIntArrayList va = new TIntArrayList(); int numPositivesInValidation = numPositives / numSteps; int numPositivesInTraining = numPositives - numPositivesInValidation; int startTrainingID = (numPositives / numSteps) * step; int endTrainingID = (startTrainingID + numPositivesInTraining - 1); TIntIntHashMap map = new TIntIntHashMap(); for (int i = startTrainingID; i <= endTrainingID; i++) { int v = i % numPositives; map.put(v, v); } int curDoc = 0; IIntIterator docs = index.getDocumentDB().getDocuments(); while (docs.hasNext()) { int docID = docs.next(); if (map.containsKey(curDoc)) { tr.add(docID); } else { va.add(docID); } curDoc++; } tr.sort(); va.sort(); IIndex trIndex = index.cloneIndex(); trIndex.removeDocuments(new TIntArrayListIterator(va), false); IIndex vaIndex = index.cloneIndex(); vaIndex.removeDocuments(new TIntArrayListIterator(tr), false); JatecsLogger.status().println("done. The training contains " + tr.size() + " document(s) and the validation contains " + va.size() + " document(s)."); Pair<IIndex, IIndex> ret = new Pair<IIndex, IIndex>(trIndex, vaIndex); return ret; }
Example 15
Source File: CRDCSSingleLabelKnnFoldValidator.java From jatecs with GNU General Public License v3.0 | 4 votes |
public static Pair<IIndex, IIndex> splitIndex(int step, IIndex index, int numValidationSteps) { int numPositives = index.getDocumentDB().getDocumentsCount(); int numSteps = Math.min(numPositives, numValidationSteps); if (step >= numSteps) return null; TIntArrayList tr = new TIntArrayList(); TIntArrayList va = new TIntArrayList(); int numPositivesInValidation = numPositives / numSteps; int numPositivesInTraining = numPositives - numPositivesInValidation; int startTrainingID = (numPositives / numSteps) * step; int endTrainingID = (startTrainingID + numPositivesInTraining - 1); TIntIntHashMap map = new TIntIntHashMap(); for (int i = startTrainingID; i <= endTrainingID; i++) { int v = i % numPositives; map.put(v, v); } int curDoc = 0; IIntIterator docs = index.getDocumentDB().getDocuments(); while (docs.hasNext()) { int docID = docs.next(); if (map.containsKey(curDoc)) { tr.add(docID); } else { va.add(docID); } curDoc++; } tr.sort(); va.sort(); IIndex trIndex = index.cloneIndex(); trIndex.removeDocuments(new TIntArrayListIterator(va), false); IIndex vaIndex = index.cloneIndex(); vaIndex.removeDocuments(new TIntArrayListIterator(tr), false); JatecsLogger.status().println( "done. The training contains " + tr.size() + " document(s) and the validation contains " + va.size() + " document(s)."); Pair<IIndex, IIndex> ret = new Pair<IIndex, IIndex>(trIndex, vaIndex); return ret; }