/** * Inserts the array of <tt>values</tt> into the list at * <tt>offset</tt>. All values including and to the right of * <tt>offset</tt> are shifted to the right. * * @param offset an <code>int</code> value * @param values an <code>int[]</code> value */ public void insert(int offset, int[] values) { insert(offset, values, 0, values.length); }
/** Returns true iff we did not already have a posting for this document */ public boolean addOrUpdateFreq(int docid, int freq) { int index = pl_doc.binarySearch(docid); if (index >= 0) { pl_freq.setQuick(index, freq + pl_freq.get(index)); return false; } else { pl_doc.insert( -(index +1), docid); pl_freq.insert( -(index +1), freq); return true; } }
protected void internalAdd(final int _i, final int _v) { if (_i == list_.size()) { list_.add(_v); } else { list_.insert(_i, _v); } }
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); } } } } }
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); } } } } }
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); }
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); }