Java Code Examples for gnu.trove.TIntArrayList#binarySearch()
The following examples show how to use
gnu.trove.TIntArrayList#binarySearch() .
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: TroveClassificationILDBBuilder.java From jatecs with GNU General Public License v3.0 | 6 votes |
protected void addCategoryHierarchicaly(int document, short category, boolean primary) { TIntArrayList docs = _classificationDB._categoriesDocuments.get(category); Vector<Boolean> docsPrimary = _classificationDB._categoriesDocumentsPrimary.get(category); int pos = docs.binarySearch(document); if (pos < 0) { docs.insert(-pos - 1, document); docsPrimary.insertElementAt(primary, -pos - 1); } else { if (primary) { docsPrimary.set(pos, true); } } IShortIterator parents = _classificationDB.getCategoryDB().getParentCategories(category); while (parents.hasNext()) addCategoryHierarchicaly(document, parents.next(), primary); }
Example 2
Source File: TroveClassificationFullDBBuilder.java From jatecs with GNU General Public License v3.0 | 6 votes |
protected void addCategoryHierarchicaly(int document, short category, boolean primary) { TShortArrayList cats = _classificationDB._documentsCategories.get(document); Vector<Boolean> catsPrimary = _classificationDB._documentsCatsPrimary.get(document); int pos = cats.binarySearch(category); if (pos < 0) { cats.insert(-pos - 1, category); catsPrimary.insertElementAt(primary, -pos - 1); } else { if (primary) { catsPrimary.set(pos, true); } } TIntArrayList docs = _classificationDB._categoriesDocuments.get(category); pos = docs.binarySearch(document); if (pos < 0) { docs.insert(-pos - 1, document); } IShortIterator parents = _classificationDB.getCategoryDB().getParentCategories(category); while (parents.hasNext()) addCategoryHierarchicaly(document, parents.next(), primary); }
Example 3
Source File: TroveDomainDB.java From jatecs with GNU General Public License v3.0 | 5 votes |
public void removeCategoryFeatures(short category, IIntIterator removedFeatures) { TIntArrayList feats = _categoriesFeatures.get(category); while (removedFeatures.hasNext()) { int feature = removedFeatures.next(); if (feats.binarySearch(feature) < 0) feats.add(feature); } feats.sort(); _hasLocalRepresentation = _hasLocalRepresentation || feats.size() > 0; }
Example 4
Source File: TroveContentDBBuilder.java From jatecs with GNU General Public License v3.0 | 5 votes |
public void setDocumentFeatureFrequency(int document, int feature, int frequency) { if (document >= 0) { int size = _contentDB._documentsFeatures.size(); if (document >= size) { for (int i = size; i <= document; ++i) { _contentDB._documentsFeatures.add(new TIntArrayList()); _contentDB._documentsFrequencies.add(new TIntArrayList()); } } if (feature >= 0) { TIntArrayList feats = _contentDB._documentsFeatures.get(document); TIntArrayList freqs = _contentDB._documentsFrequencies.get(document); int pos = feats.binarySearch(feature); if (pos < 0 && frequency > 0) { pos = -pos - 1; feats.insert(pos, feature); freqs.insert(pos, frequency); } else { if (frequency > 0) { freqs.setQuick(pos, frequency); } else { feats.remove(pos); freqs.remove(pos); } } } } }
Example 5
Source File: TroveContentILDBBuilder.java From jatecs with GNU General Public License v3.0 | 5 votes |
public void setDocumentFeatureFrequency(int document, int feature, int frequency) { if (feature >= 0) { int size = _contentDB._featuresDocuments.size(); if (feature >= size) { for (int i = size; i <= feature; ++i) { _contentDB._featuresDocuments.add(new TIntArrayList()); _contentDB._featuresFrequencies.add(new TIntArrayList()); } } if (document >= 0) { TIntArrayList docs = _contentDB._featuresDocuments.get(feature); TIntArrayList freqs = _contentDB._featuresFrequencies .get(feature); int pos = docs.binarySearch(document); if (pos < 0 && frequency > 0) { pos = -pos - 1; docs.insert(pos, document); freqs.insert(pos, frequency); } else { if (frequency > 0) { freqs.setQuick(pos, frequency); } else { docs.remove(pos); freqs.remove(pos); } } } } }