Java Code Examples for gnu.trove.TIntArrayList#remove()

The following examples show how to use gnu.trove.TIntArrayList#remove() . 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: TroveContentDBBuilder.java    From jatecs with GNU General Public License v3.0 5 votes vote down vote up
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 2
Source File: TroveContentILDBBuilder.java    From jatecs with GNU General Public License v3.0 5 votes vote down vote up
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);
                }
            }
        }
    }
}
 
Example 3
Source File: TroveContentDB.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
public void removeFeatures(IIntIterator removedFeatures) {
    for (int i = 0; i < _documentsFeatures.size(); ++i) {
        TIntArrayList feats = _documentsFeatures.get(i);
        TIntArrayList freqs = _documentsFrequencies.get(i);
        int j = 0;
        int shift = 0;
        int feat;
        int rem;
        if (j < feats.size() && removedFeatures.hasNext()) {
            feat = feats.getQuick(j);
            rem = removedFeatures.next();

            while (true) {
                if (feat == rem) {
                    feats.remove(j);
                    freqs.remove(j);
                    if (j < feats.size() && removedFeatures.hasNext()) {
                        feat = feats.getQuick(j);
                        rem = removedFeatures.next();
                        ++shift;
                    } else
                        break;
                } else if (feat > rem) {
                    if (removedFeatures.hasNext()) {
                        rem = removedFeatures.next();
                        ++shift;
                    } else
                        break;
                } else {
                    feats.setQuick(j, feat - shift);
                    ++j;
                    if (j < feats.size())
                        feat = feats.getQuick(j);
                    else
                        break;
                }
            }
            ++shift;
        }

        while (j < feats.size()) {
            feats.setQuick(j, feats.getQuick(j) - shift);
            ++j;
        }
        removedFeatures.begin();
    }
    _documentLenghts.clear();
    _featureDocumentsCount.clear();
}
 
Example 4
Source File: TroveClassificationILDB.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
public void removeDocuments(IIntIterator removedDocuments) {
    for (int i = 0; i < _categoriesDocuments.size(); ++i) {
        TIntArrayList docs = _categoriesDocuments.get(i);
        Vector<Boolean> docsPrimary = _categoriesDocumentsPrimary.get(i);
        int j = 0;
        int shift = 0;
        int doc;
        int rem;
        if (j < docs.size() && removedDocuments.hasNext()) {
            doc = docs.getQuick(j);
            rem = removedDocuments.next();

            while (true) {
                if (doc == rem) {
                    docs.remove(j);
                    docsPrimary.remove(j);
                    if (j < docs.size() && removedDocuments.hasNext()) {
                        doc = docs.getQuick(j);
                        rem = removedDocuments.next();
                        ++shift;
                    } else
                        break;
                } else if (doc > rem) {
                    if (removedDocuments.hasNext()) {
                        rem = removedDocuments.next();
                        ++shift;
                    } else
                        break;
                } else {
                    docs.setQuick(j, doc - shift);
                    ++j;
                    if (j < docs.size())
                        doc = docs.getQuick(j);
                    else
                        break;
                }
            }
            ++shift;
        }
        while (j < docs.size()) {
            docs.setQuick(j, docs.getQuick(j) - shift);
            ++j;
        }
        removedDocuments.begin();
    }
}
 
Example 5
Source File: TroveWeightingDB.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
public void removeFeatures(IIntIterator removedFeatures) {
    for (int i = 0; i < _documentsWeights.size(); ++i) {
        TIntDoubleHashMap weigs = _documentsWeights.get(i);
        TIntArrayList feats = new TIntArrayList(weigs.size());
        TDoubleArrayList weigths = new TDoubleArrayList(weigs.size());
        TIntDoubleIterator wit = weigs.iterator();
        while (wit.hasNext()) {
            wit.advance();
            feats.add(wit.key());
            weigths.add(wit.value());
        }
        int j = 0;
        int shift = 0;
        int feat;
        int rem;
        if (j < feats.size() && removedFeatures.hasNext()) {
            feat = feats.getQuick(j);
            rem = removedFeatures.next();

            while (true) {
                if (feat == rem) {
                    feats.remove(j);
                    weigths.remove(j);
                    if (j < feats.size() && removedFeatures.hasNext()) {
                        feat = feats.getQuick(j);
                        rem = removedFeatures.next();
                        ++shift;
                    } else
                        break;
                } else if (feat > rem) {
                    if (removedFeatures.hasNext()) {
                        rem = removedFeatures.next();
                        ++shift;
                    } else
                        break;
                } else {
                    feats.setQuick(j, feat - shift);
                    ++j;
                    if (j < feats.size())
                        feat = feats.getQuick(j);
                    else
                        break;
                }
            }
            ++shift;
        }
        while (j < feats.size()) {
            feats.setQuick(j, feats.getQuick(j) - shift);
            ++j;
        }

        weigs.clear();
        for (j = 0; j < feats.size(); ++j)
            weigs.put(feats.getQuick(j), weigths.getQuick(j));

        removedFeatures.begin();
    }
}
 
Example 6
Source File: TroveDomainDB.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
public void removeFeatures(IIntIterator removedFeatures) {
    for (int i = 0; i < _categoriesFeatures.size(); ++i) {
        TIntArrayList feats = _categoriesFeatures.get(i);
        int j = 0;
        int shift = 0;
        int feat;
        int rem;
        if (j < feats.size() && removedFeatures.hasNext()) {
            feat = feats.getQuick(j);
            rem = removedFeatures.next();

            while (true) {
                if (feat == rem) {
                    feats.remove(j);
                    if (j < feats.size() && removedFeatures.hasNext()) {
                        feat = feats.getQuick(j);
                        rem = removedFeatures.next();
                        ++shift;
                    } else
                        break;
                } else if (feat > rem) {
                    if (removedFeatures.hasNext()) {
                        rem = removedFeatures.next();
                        ++shift;
                    } else
                        break;
                } else {
                    feats.setQuick(j, feat - shift);
                    ++j;
                    if (j < feats.size())
                        feat = feats.getQuick(j);
                    else
                        break;
                }
            }
        }
        while (j < feats.size()) {
            feats.setQuick(j, feats.getQuick(j) - shift);
            ++j;
        }
        removedFeatures.begin();
    }
}
 
Example 7
Source File: TroveContentILDB.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
public void removeDocuments(IIntIterator removedDocuments) {
    for (int i = 0; i < _featuresDocuments.size(); ++i) {
        TIntArrayList docs = _featuresDocuments.get(i);
        TIntArrayList freqs = _featuresFrequencies.get(i);
        int j = 0;
        int shift = 0;
        int doc;
        int rem;
        if (j < docs.size() && removedDocuments.hasNext()) {
            doc = docs.getQuick(j);
            rem = removedDocuments.next();

            while (true) {
                if (doc == rem) {
                    docs.remove(j);
                    freqs.remove(j);
                    if (j < docs.size() && removedDocuments.hasNext()) {
                        doc = docs.getQuick(j);
                        rem = removedDocuments.next();
                        ++shift;
                    } else
                        break;
                } else if (doc > rem) {
                    if (removedDocuments.hasNext()) {
                        rem = removedDocuments.next();
                        ++shift;
                    } else
                        break;
                } else {
                    docs.setQuick(j, doc - shift);
                    ++j;
                    if (j < docs.size())
                        doc = docs.getQuick(j);
                    else
                        break;
                }
            }
            ++shift;
        }
        while (j < docs.size()) {
            docs.setQuick(j, docs.getQuick(j) - shift);
            ++j;
        }
        removedDocuments.begin();
    }
    removedDocuments.begin();
    while (removedDocuments.hasNext()) {
        int document = removedDocuments.next();
        _documentFeaturesCount.remove(document);
        _documentLenghts.remove(document);
    }

}
 
Example 8
Source File: TroveContentFullDB.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
public void removeFeatures(IIntIterator removedFeatures) {
    int shift = 0;
    while (removedFeatures.hasNext()) {
        int feature = removedFeatures.next() - shift;
        _featuresDocuments.remove(feature);
        _featuresFrequencies.remove(feature);
        ++shift;
    }
    removedFeatures.begin();
    for (int i = 0; i < _documentsFeatures.size(); ++i) {
        TIntArrayList feats = _documentsFeatures.get(i);
        TIntArrayList freqs = _documentsFrequencies.get(i);
        int j = 0;
        shift = 0;
        int feat;
        int rem;
        if (j < feats.size() && removedFeatures.hasNext()) {
            feat = feats.getQuick(j);
            rem = removedFeatures.next();

            while (true) {
                if (feat == rem) {
                    feats.remove(j);
                    freqs.remove(j);
                    if (j < feats.size() && removedFeatures.hasNext()) {
                        feat = feats.getQuick(j);
                        rem = removedFeatures.next();
                        ++shift;
                    } else
                        break;
                } else if (feat > rem) {
                    if (removedFeatures.hasNext()) {
                        rem = removedFeatures.next();
                        ++shift;
                    } else
                        break;
                } else {
                    feats.setQuick(j, feat - shift);
                    ++j;
                    if (j < feats.size())
                        feat = feats.getQuick(j);
                    else
                        break;
                }
            }
            ++shift;
        }
        while (j < feats.size()) {
            feats.setQuick(j, feats.getQuick(j) - shift);
            ++j;
        }
        removedFeatures.begin();
    }
    _documentLenghts.clear();
}