gnu.trove.TIntIntHashMap Java Examples

The following examples show how to use gnu.trove.TIntIntHashMap. 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: IntToIntBtree.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: BlazeCoverageData.java    From intellij with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: SrcFileAnnotator.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: TroveContentFullDB.java    From jatecs with GNU General Public License v3.0 6 votes vote down vote up
public TroveContentFullDB(IDocumentDB documentsDB, IFeatureDB featuresDB) {
    super();
    _documentsDB = documentsDB;
    _featuresDB = featuresDB;

    int sizeDocs = documentsDB.getDocumentsCount();
    _documentsFeatures = new Vector<TIntArrayList>(sizeDocs);
    _documentsFrequencies = new Vector<TIntArrayList>(sizeDocs);
    for (int i = 0; i < sizeDocs; ++i) {
        _documentsFeatures.add(new TIntArrayList());
        _documentsFrequencies.add(new TIntArrayList());
    }

    int sizeFeats = featuresDB.getFeaturesCount();
    _featuresDocuments = new Vector<TIntArrayList>(sizeFeats);
    _featuresFrequencies = new Vector<TIntArrayList>(sizeFeats);
    for (int i = 0; i < sizeFeats; ++i) {
        _featuresDocuments.add(new TIntArrayList());
        _featuresFrequencies.add(new TIntArrayList());
    }

    _documentLenghts = new TIntIntHashMap();

    _name = "generic";
}
 
Example #5
Source File: TroveContentILDB.java    From jatecs with GNU General Public License v3.0 6 votes vote down vote up
public IContentDB cloneDB(IDocumentDB documentsDB, IFeatureDB featuresDB) {
    TroveContentILDB contentDB = new TroveContentILDB(documentsDB,
            featuresDB);
    contentDB._name = new String(_name);

    contentDB._featuresDocuments = new Vector<TIntArrayList>(
            _featuresDocuments.size());
    for (int i = 0; i < _featuresDocuments.size(); ++i)
        contentDB._featuresDocuments.add((TIntArrayList) _featuresDocuments
                .get(i).clone());

    contentDB._documentFeaturesCount = (TIntIntHashMap) _documentFeaturesCount
            .clone();
    contentDB._documentLenghts = (TIntIntHashMap) _documentLenghts.clone();

    contentDB._featuresFrequencies = new Vector<TIntArrayList>(
            _featuresFrequencies.size());
    for (int i = 0; i < _featuresFrequencies.size(); ++i)
        contentDB._featuresFrequencies
                .add((TIntArrayList) _featuresFrequencies.get(i).clone());

    return contentDB;
}
 
Example #6
Source File: TroveContentILDB.java    From jatecs with GNU General Public License v3.0 6 votes vote down vote up
public TroveContentILDB(IDocumentDB documentsDB, IFeatureDB featuresDB) {
    super();
    _documentsDB = documentsDB;
    _featuresDB = featuresDB;

    int size = featuresDB.getFeaturesCount();
    _featuresDocuments = new Vector<TIntArrayList>(size);
    _featuresFrequencies = new Vector<TIntArrayList>(size);
    for (int i = 0; i < size; ++i) {
        _featuresDocuments.add(new TIntArrayList());
        _featuresFrequencies.add(new TIntArrayList());
    }

    _documentLenghts = new TIntIntHashMap();
    _documentFeaturesCount = new TIntIntHashMap();
    _name = "generic";
}
 
Example #7
Source File: NameSuggester.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #8
Source File: TroveContentDB.java    From jatecs with GNU General Public License v3.0 6 votes vote down vote up
public IContentDB cloneDB(IDocumentDB docDB, IFeatureDB featDB) {
    TroveContentDB contentDB = new TroveContentDB(docDB, featDB);
    contentDB._name = new String(_name);

    contentDB._documentsFeatures = new Vector<TIntArrayList>(
            _documentsFeatures.size());
    for (int i = 0; i < _documentsFeatures.size(); ++i)
        contentDB._documentsFeatures.add((TIntArrayList) _documentsFeatures
                .get(i).clone());

    contentDB._documentsFrequencies = new Vector<TIntArrayList>(
            _documentsFrequencies.size());
    for (int i = 0; i < _documentsFrequencies.size(); ++i)
        contentDB._documentsFrequencies
                .add((TIntArrayList) _documentsFrequencies.get(i).clone());

    contentDB._documentLenghts = (TIntIntHashMap) _documentLenghts.clone();
    contentDB._featureDocumentsCount = (TIntIntHashMap) _featureDocumentsCount
            .clone();

    return contentDB;
}
 
Example #9
Source File: TroveContentDB.java    From jatecs with GNU General Public License v3.0 6 votes vote down vote up
public TroveContentDB(IDocumentDB documentsDB, IFeatureDB featuresDB) {
    super();
    _documentsDB = documentsDB;
    _featuresDB = featuresDB;

    int size = documentsDB.getDocumentsCount();
    _documentsFeatures = new Vector<TIntArrayList>(size);
    _documentsFrequencies = new Vector<TIntArrayList>(size);
    for (int i = 0; i < size; ++i) {
        _documentsFeatures.add(new TIntArrayList());
        _documentsFrequencies.add(new TIntArrayList());
    }

    _documentLenghts = new TIntIntHashMap();
    _featureDocumentsCount = new TIntIntHashMap();
    _name = "generic";
}
 
Example #10
Source File: NameSuggester.java    From consulo with Apache License 2.0 5 votes vote down vote up
public String suggestName(final String propertyName) {
  if (myOldClassNameAsGiven.equals(propertyName)) return myNewClassNameAsGiven;
  final String[] propertyWords = NameUtil.splitNameIntoWords(propertyName);
  TIntIntHashMap matches = calculateMatches(propertyWords);
  if (matches.isEmpty()) return propertyName;
  TreeMap<Pair<Integer,Integer>, String> replacements = calculateReplacements(propertyWords, matches);
  if (replacements.isEmpty()) return propertyName;
  return calculateNewName(replacements, propertyWords, propertyName);
}
 
Example #11
Source File: IndentUsageStatisticsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static List<IndentUsageInfo> toIndentUsageList(@Nonnull TIntIntHashMap indentToUsages) {
  List<IndentUsageInfo> indentUsageInfos = ContainerUtil.newArrayList();
  TIntIntIterator it = indentToUsages.iterator();
  while (it.hasNext()) {
    it.advance();
    indentUsageInfos.add(new IndentUsageInfo(it.key(), it.value()));
  }
  return indentUsageInfos;
}
 
Example #12
Source File: Util.java    From whyline with MIT License 5 votes vote down vote up
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 #13
Source File: DeleteToWordStartAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #14
Source File: AbstractDataGetter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 #15
Source File: AbstractDataGetter.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #16
Source File: AbstractDataGetter.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void sortCommitsByRow(@Nonnull List<T> result, @Nonnull final TIntIntHashMap rowsForCommits) {
  ContainerUtil.sort(result, (details1, details2) -> {
    int row1 = rowsForCommits.get(myHashMap.getCommitIndex(details1.getId(), details1.getRoot()));
    int row2 = rowsForCommits.get(myHashMap.getCommitIndex(details2.getId(), details2.getRoot()));
    return Comparing.compare(row1, row2);
  });
}
 
Example #17
Source File: SimpleColoredComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public SimpleColoredComponent() {
  myFragments = new ArrayList<String>(3);
  myAttributes = new ArrayList<SimpleTextAttributes>(3);
  myIpad = new JBInsets(1, 2, 1, 2);
  myIconTextGap = JBUI.scale(2);
  myBorder = new MyBorder();
  myFragmentPadding = new TIntIntHashMap(10);
  myFragmentAlignment = new TIntIntHashMap(10);
  setOpaque(true);

  updateUI();
}
 
Example #18
Source File: SrcFileAnnotator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
private SoftReference<TIntIntHashMap> doGetLineMapping(final long date, boolean oldToNew) {
  final VirtualFile f = getVirtualFile();
  final byte[] oldContent;
  synchronized (LOCK) {
    if (myOldContent == null) {
      if (ApplicationManager.getApplication().isDispatchThread()) return null;
      final byte[] byteContent = LocalHistory.getInstance().getByteContent(f, new FileRevisionTimestampComparator() {
        public boolean isSuitable(long revisionTimestamp) {
          return revisionTimestamp < date;
        }
      });
      myOldContent = new SoftReference<byte[]>(byteContent);
    }
    oldContent = myOldContent.get();
  }

  if (oldContent == null) return null;
  String[] coveredLines = getCoveredLines(oldContent, f);
  String[] currentLines = getUpToDateLines();

  String[] oldLines = oldToNew ? coveredLines : currentLines;
  String[] newLines = oldToNew ? currentLines : coveredLines;

  Diff.Change change = null;
  try {
    change = Diff.buildChanges(oldLines, newLines);
  }
  catch (FilesTooBigForDiffException e) {
    LOG.info(e);
    return null;
  }
  return new SoftReference<TIntIntHashMap>(getCoverageVersionToCurrentLineMapping(change, oldLines.length));
}
 
Example #19
Source File: SrcFileAnnotator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
private TIntIntHashMap getNewToOldLineMapping(final long date) {
  if (myNewToOldLines == null) {
    myNewToOldLines = doGetLineMapping(date, false);
    if (myNewToOldLines == null) return null;
  }
  return myNewToOldLines.get();
}
 
Example #20
Source File: SrcFileAnnotator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private TIntIntHashMap getOldToNewLineMapping(final long date) {
  if (myOldToNewLines == null) {
    myOldToNewLines = doGetLineMapping(date, true);
    if (myOldToNewLines == null) return null;
  }
  return myOldToNewLines.get();
}
 
Example #21
Source File: TracingData.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #22
Source File: CoTrainer.java    From jatecs with GNU General Public License v3.0 5 votes vote down vote up
protected IIndex createEnrichedTraining(TIntIntHashMap map, IIndex testAllCats, IIndex training) {
    IIndex idx = training.cloneIndex();
    TroveMainIndexBuilder builder = new TroveMainIndexBuilder(idx);
    int numDocs = training.getDocumentDB().getDocumentsCount();

    int[] keys = map.keys();
    for (int i = 0; i < keys.length; i++) {
        int docID = keys[i];
        ArrayList<String> features = new ArrayList<String>(100);
        String docName = "" + (numDocs + (i + 1));
        IIntIterator feats = testAllCats.getContentDB().getDocumentFeatures(docID);
        while (feats.hasNext()) {
            int featID = feats.next();
            String featName = testAllCats.getFeatureDB().getFeatureName(featID);
            int count = testAllCats.getContentDB().getDocumentFeatureFrequency(docID, featID);
            for (int j = 0; j < count; j++)
                features.add(featName);
        }

        ArrayList<String> categories = new ArrayList<String>();
        IShortIterator cats = testAllCats.getClassificationDB().getDocumentCategories(docID);
        while (cats.hasNext()) {
            short catID = cats.next();
            String catName = testAllCats.getCategoryDB().getCategoryName(catID);
            categories.add(catName);
        }

        builder.addDocument(docName, features.toArray(new String[0]), categories.toArray(new String[0]));
    }

    return idx;
}
 
Example #23
Source File: Util.java    From whyline with MIT License 5 votes vote down vote up
public static void writeIntIntMap(DataOutputStream stream, TIntIntHashMap map) throws IOException {
	
	stream.writeInt(map.size());
	for(int key : map.keys()) {
		stream.writeInt(key);
		stream.writeInt(map.get(key));
	}
	
}
 
Example #24
Source File: TroveDocumentsDB.java    From jatecs with GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source File: TroveContentFullDB.java    From jatecs with GNU General Public License v3.0 5 votes vote down vote up
public IContentDB cloneDB(IDocumentDB docDB, IFeatureDB featDB) {
    TroveContentFullDB contentDB = new TroveContentFullDB(docDB, featDB);
    contentDB._name = new String(_name);

    contentDB._documentsFeatures = new Vector<TIntArrayList>(
            _documentsFeatures.size());
    for (int i = 0; i < _documentsFeatures.size(); ++i)
        contentDB._documentsFeatures.add((TIntArrayList) _documentsFeatures
                .get(i).clone());

    contentDB._documentsFrequencies = new Vector<TIntArrayList>(
            _documentsFrequencies.size());
    for (int i = 0; i < _documentsFrequencies.size(); ++i)
        contentDB._documentsFrequencies
                .add((TIntArrayList) _documentsFrequencies.get(i).clone());

    contentDB._documentLenghts = (TIntIntHashMap) _documentLenghts.clone();

    contentDB._featuresDocuments = new Vector<TIntArrayList>(
            _featuresDocuments.size());
    for (int i = 0; i < _featuresDocuments.size(); ++i)
        contentDB._featuresDocuments.add((TIntArrayList) _featuresDocuments
                .get(i).clone());

    contentDB._featuresFrequencies = new Vector<TIntArrayList>(
            _featuresFrequencies.size());
    for (int i = 0; i < _featuresFrequencies.size(); ++i)
        contentDB._featuresFrequencies
                .add((TIntArrayList) _featuresFrequencies.get(i).clone());

    return contentDB;
}
 
Example #26
Source File: TroveFeaturesDB.java    From jatecs with GNU General Public License v3.0 5 votes vote down vote up
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 #27
Source File: BlazeCoverageData.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static BlazeCoverageData parse(InputStream inputStream) throws IOException {
  Map<String, FileData> map = new HashMap<>();
  BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, UTF_8));
  String line;
  while ((line = reader.readLine()) != null) {
    if (line.startsWith(SF)) {
      String source = line.substring(SF.length());
      TIntIntHashMap hits = parseHits(reader);
      if (!hits.isEmpty()) {
        map.put(source, new FileData(source, hits));
      }
    }
  }
  return new BlazeCoverageData(ImmutableMap.copyOf(map));
}
 
Example #28
Source File: MultiIconSimpleColoredComponent.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public MultiIconSimpleColoredComponent() {
  myFragments = new ArrayList<>(3);
  myLayouts = new ArrayList<>(3);
  myAttributes = new ArrayList<>(3);
  myIcons = new ArrayList<>(3);
  myIpad = new JBInsets(1, 2, 1, 2);
  myIconTextGap = JBUI.scale(2);
  myBorder = new MyBorder();
  myFragmentPadding = new TIntIntHashMap(10);
  myFragmentAlignment = new TIntIntHashMap(10);
  setOpaque(true);
  updateUI();
}
 
Example #29
Source File: MultiIconSimpleColoredComponent.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public MultiIconSimpleColoredComponent() {
  myFragments = new ArrayList<>(3);
  myLayouts = new ArrayList<>(3);
  myAttributes = new ArrayList<>(3);
  myIcons = new ArrayList<>(3);
  myIpad = new JBInsets(1, 2, 1, 2);
  myIconTextGap = JBUI.scale(2);
  myBorder = new MyBorder();
  myFragmentPadding = new TIntIntHashMap(10);
  myFragmentAlignment = new TIntIntHashMap(10);
  setOpaque(true);
  updateUI();
}
 
Example #30
Source File: WMVSingleLabelKnnFoldValidator.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
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;

}