本文整理汇总了Java中gnu.trove.TIntArrayList.clear方法的典型用法代码示例。如果您正苦于以下问题:Java TIntArrayList.clear方法的具体用法?Java TIntArrayList.clear怎么用?Java TIntArrayList.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.TIntArrayList
的用法示例。
在下文中一共展示了TIntArrayList.clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEmptyIntArray
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@NotNull
private TIntArrayList getEmptyIntArray() {
if (intArrayPool.isEmpty()) {
return new TIntArrayList(1);
}
TIntArrayList list = intArrayPool.pop();
list.clear();
return list;
}
示例2: printDocumentsClassificationStatistics
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
/**
* Print statistics about document and classification.
*
* @param docsDB The documents DB.
* @param classificationDB The classification DB.
* @param wantDetails True if must print more details about the statistics, false
* otherwise.
*/
public static void printDocumentsClassificationStatistics(
IDocumentDB docsDB, IClassificationDB classificationDB,
boolean wantDetails) {
if (docsDB == null)
throw new NullPointerException(
"The specified documents DB is 'null'");
if (classificationDB == null)
throw new NullPointerException(
"The specified classification DB is 'null'");
int docsCount = docsDB.getDocumentsCount();
double avgCatsPerDoc = 0.0;
int minCatsPerDoc = Integer.MAX_VALUE;
TIntArrayList minCatsPerDocDocs = new TIntArrayList();
int maxCatsPerDoc = Integer.MIN_VALUE;
TIntArrayList maxCatsPerDocDocs = new TIntArrayList();
IIntIterator docIt = docsDB.getDocuments();
docIt.begin();
while (docIt.hasNext()) {
int doc = docIt.next();
int docCats = classificationDB.getDocumentCategoriesCount(doc);
if (docCats == minCatsPerDoc)
minCatsPerDocDocs.add(doc);
if (docCats < minCatsPerDoc) {
minCatsPerDoc = docCats;
minCatsPerDocDocs.clear();
minCatsPerDocDocs.add(doc);
}
if (docCats == maxCatsPerDoc)
maxCatsPerDocDocs.add(doc);
if (docCats > maxCatsPerDoc) {
maxCatsPerDoc = docCats;
maxCatsPerDocDocs.clear();
maxCatsPerDocDocs.add(doc);
}
avgCatsPerDoc += docCats;
}
avgCatsPerDoc /= docsCount;
JatecsLogger.status().println("");
JatecsLogger.status().println(
"Average categories per documents: "
+ Os.generateDouble(avgCatsPerDoc, 3));
JatecsLogger.status().print(
"Maximum categories per documents: ["
+ maxCatsPerDocDocs.size() + "] " + maxCatsPerDoc
+ " (");
if (wantDetails) {
for (int i = 0; i < maxCatsPerDocDocs.size(); ++i) {
JatecsLogger.status().print(
docsDB.getDocumentName(maxCatsPerDocDocs.get(i)) + " ");
}
}
JatecsLogger.status().println(")");
JatecsLogger.status().print(
"Minimum categories per documents: ["
+ minCatsPerDocDocs.size() + "] " + minCatsPerDoc
+ " (");
if (wantDetails) {
for (int i = 0; i < minCatsPerDocDocs.size(); ++i) {
JatecsLogger.status().print(
docsDB.getDocumentName(minCatsPerDocDocs.get(i)) + " ");
}
}
}