本文整理汇总了Java中gnu.trove.TIntArrayList.getQuick方法的典型用法代码示例。如果您正苦于以下问题:Java TIntArrayList.getQuick方法的具体用法?Java TIntArrayList.getQuick怎么用?Java TIntArrayList.getQuick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.TIntArrayList
的用法示例。
在下文中一共展示了TIntArrayList.getQuick方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@Override
public void save(@NotNull DataOutput out, TIntArrayList list) throws IOException {
if (list.size() == 2) {
DataInputOutputUtil.writeINT(out, list.getQuick(0));
DataInputOutputUtil.writeINT(out, list.getQuick(1));
}
else {
DataInputOutputUtil.writeINT(out, -list.size());
int prev = 0;
for (int i = 0, len = list.size(); i < len; i+=2) {
int value = list.getQuick(i);
DataInputOutputUtil.writeINT(out, value - prev);
prev = value;
DataInputOutputUtil.writeINT(out, list.getQuick(i + 1));
}
}
}
示例2: getDocumentLength
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
public int getDocumentLength(int document) {
if (_documentLenghts.containsKey(document))
return _documentLenghts.get(document);
else {
if (document < _documentsFrequencies.size()) {
TIntArrayList frequencies = _documentsFrequencies.get(document);
int length = 0;
for (int i = 0; i < frequencies.size(); ++i)
length += frequencies.getQuick(i);
_documentLenghts.put(document, length);
return length;
} else
return 0;
}
}
示例3: unescapePercentSequences
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@NotNull
public static String unescapePercentSequences(@NotNull String s) {
if (s.indexOf('%') == -1) {
return s;
}
StringBuilder decoded = new StringBuilder();
final int len = s.length();
int i = 0;
while (i < len) {
char c = s.charAt(i);
if (c == '%') {
TIntArrayList bytes = new TIntArrayList();
while (i + 2 < len && s.charAt(i) == '%') {
final int d1 = decode(s.charAt(i + 1));
final int d2 = decode(s.charAt(i + 2));
if (d1 != -1 && d2 != -1) {
bytes.add(((d1 & 0xf) << 4 | d2 & 0xf));
i += 3;
}
else {
break;
}
}
if (!bytes.isEmpty()) {
final byte[] bytesArray = new byte[bytes.size()];
for (int j = 0; j < bytes.size(); j++) {
bytesArray[j] = (byte)bytes.getQuick(j);
}
decoded.append(new String(bytesArray, CharsetToolkit.UTF8_CHARSET));
continue;
}
}
decoded.append(c);
i++;
}
return decoded.toString();
}
示例4: removeFeatures
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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();
}
示例5: removeDocuments
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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();
}
}
示例6: removeFeatures
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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();
}
}
示例7: removeFeatures
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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();
}
}
示例8: removeDocuments
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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);
}
}
示例9: removeFeatures
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
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();
}
示例10: nextMicroTable
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
protected TIntDoubleHashMap nextMicroTable(ContingencyTableSet oldEvaluation, ContingencyTableSet newEvaluation) {
if (oldEvaluation != null && newEvaluation != null && !oldEvaluation.equals(newEvaluation)) {
ContingencyTable newContingency = newEvaluation.getGlobalContingencyTable();
ContingencyTable oldContingency = oldEvaluation.getGlobalContingencyTable();
TIntArrayList increment = new TIntArrayList(4);
increment.setQuick(0, newContingency.tp() - oldContingency.tp());
increment.setQuick(1, newContingency.tn() - oldContingency.tn());
increment.setQuick(2, newContingency.fp() - oldContingency.fp());
increment.setQuick(3, newContingency.fn() - oldContingency.fn());
if (increment.getQuick(0) != 0 || increment.getQuick(1) != 0 || increment.getQuick(2) != 0 || increment.getQuick(3) != 0) {
for (int j = 0; j < 4; j++) {
globalContingencies[j] += increment.getQuick(j);
// if (globalContingencies[j] < 0.0) {
// globalContingencies[j] = 0.0;
// }
}
double currGainFP = gain.FP(globalContingencies);
double currGainFN = gain.FN(globalContingencies);
//FIXME iter only on the not seen documents
for (int docId = 0; docId < testSize; docId++) {
if (microAlreadySeen.contains(docId)) {
continue;
}
Iterator<Entry<Short, ClassifierRangeWithScore>> iterator = classification.getDocumentScoresAsSet(docId).iterator();
while (iterator.hasNext()) {
Entry<Short, ClassifierRangeWithScore> next = iterator.next();
int catId = catMap.get(next.getKey());
ClassifierRangeWithScore value = next.getValue();
// the current gain has to be set to allow an update of the utilities
if (value.score > value.border) {
microUtilities[docId][catId] = currGainFP * probabilities[docId][catId];
} else if (value.score < value.border) {
microUtilities[docId][catId] = currGainFN * probabilities[docId][catId];
} else {
//microUtilities[docId][catId] = 1.0 * probabilities[docId][catId];
}
}
}
}
}
microRankTable.clear();
//FIXME iter only on the not seen documents
for (int docId = 0; docId < testSize; docId++) {
if (!microAlreadySeen.contains(docId)) {
double sum = 0.0;
for (int i = 0; i < microUtilities[docId].length; i++) {
sum += microUtilities[docId][i];
}
microRankTable.put(docId, sum);
}
}
microRank = null;
return microRankTable;
}
示例11: process
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@Override
public boolean process(VirtualFile file, TIntArrayList list) {
for(int i = 0, len = list.size(); i < len; i+=2) {
ProgressManager.checkCanceled();
if (list.getQuick(i + 1) != myHash2) continue;
int offset = list.getQuick(i);
if (myProjectFileIndex.isInSource(virtualFile) && !myProjectFileIndex.isInSource(file)) return true;
if (!myProjectFileIndex.isInSource(virtualFile) && myProjectFileIndex.isInSource(file)) return true;
final int startOffset = getStartOffset(myNode);
final int endOffset = getEndOffset(myNode);
if (file.equals(virtualFile) && offset >= startOffset && offset < endOffset) continue;
PsiElement target = getPsi(myNode);
TextRange rangeInElement = getRangeInElement(myNode);
Integer fragmentStartOffsetInteger = startOffset;
SortedMap<Integer,TextRange> map = reportedRanges.subMap(fragmentStartOffsetInteger, endOffset);
int newFragmentSize = !map.isEmpty() ? 0:1;
Iterator<Integer> iterator = map.keySet().iterator();
while(iterator.hasNext()) {
Integer next = iterator.next();
iterator.remove();
reportedFiles.remove(next);
reportedOffsetInOtherFiles.remove(next);
reportedPsi.remove(next);
newFragmentSize += fragmentSize.remove(next);
}
reportedRanges.put(fragmentStartOffsetInteger, rangeInElement);
reportedFiles.put(fragmentStartOffsetInteger, file);
reportedOffsetInOtherFiles.put(fragmentStartOffsetInteger, offset);
reportedPsi.put(fragmentStartOffsetInteger, target);
fragmentSize.put(fragmentStartOffsetInteger, newFragmentSize);
if (newFragmentSize >= MIN_FRAGMENT_SIZE || isLightProfile()) {
fragmentHash.put(fragmentStartOffsetInteger, (myHash & 0xFFFFFFFFL) | ((long)myHash2 << 32));
}
return false;
}
return true;
}