本文整理汇总了Java中gnu.trove.TIntArrayList.binarySearch方法的典型用法代码示例。如果您正苦于以下问题:Java TIntArrayList.binarySearch方法的具体用法?Java TIntArrayList.binarySearch怎么用?Java TIntArrayList.binarySearch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.TIntArrayList
的用法示例。
在下文中一共展示了TIntArrayList.binarySearch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCategoryHierarchicaly
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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);
}
示例2: addCategoryHierarchicaly
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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);
}
示例3: removeCategoryFeatures
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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;
}
示例4: setDocumentFeatureFrequency
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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);
}
}
}
}
}
示例5: setDocumentFeatureFrequency
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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);
}
}
}
}
}