本文整理汇总了Java中gnu.trove.map.hash.TIntIntHashMap.size方法的典型用法代码示例。如果您正苦于以下问题:Java TIntIntHashMap.size方法的具体用法?Java TIntIntHashMap.size怎么用?Java TIntIntHashMap.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.hash.TIntIntHashMap
的用法示例。
在下文中一共展示了TIntIntHashMap.size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
/**
* start path extraction considering all the pairs main_item-items
*/
private void start(){
TIntIntHashMap paths = null;
String item_pair_paths = "";
for(int j = 0; j < items.size(); j++){
ItemTree b = items.get(j);
int b_id = b.getItemId();
paths = computePaths(main_item, b);
if(paths.size() > 0){
item_pair_paths = main_item_id + "-" + b_id + "\t";
TIntIntIterator it = paths.iterator();
while(it.hasNext()){
it.advance();
item_pair_paths += it.key() + "=" + it.value() + ",";
}
item_pair_paths = item_pair_paths.substring(0, item_pair_paths.length()-1);
// text file writing
if(textWriter != null)
textWriter.write(item_pair_paths);
// binary file writing
if(pathWriter != null)
pathWriter.write(item_pair_paths);
if(computeInversePaths){
item_pair_paths = b_id + "-" + main_item_id + "\t";
it = paths.iterator();
while(it.hasNext()){
it.advance();
item_pair_paths += reverse(it.key()) + "=" + it.value() + ",";
}
item_pair_paths = item_pair_paths.substring(0, item_pair_paths.length()-1);
// text file writing
if(textWriter != null)
textWriter.write(item_pair_paths);
// binary file writing
if(pathWriter != null){
pathWriter.write(item_pair_paths);
}
}
}
}
}
示例2: buildFeatureVector
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
private void buildFeatureVector(int item_id, TIntIntHashMap paths) {
try {
double rate = 0;
double n = 1;
boolean training = false, validation = false;
DecimalFormat form = new DecimalFormat("#.####");
form.setRoundingMode(RoundingMode.CEILING);
StringBuffer str = new StringBuffer();
if (trainRatings.containsKey(item_id)) {
training = true;
rate = trainRatings.get(item_id);
} else if (validationRatings.containsKey(item_id)) {
validation = true;
rate = validationRatings.get(item_id);
}
if (normalize)
n = norm(paths);
str.append(rate + " qid:" + user_id + " 1:" + item_id + " ");
for (int i = 1; i <= path_index.size(); i++) {
int count = 0;
if (paths.size() == 1)
n = norm(paths);
if (paths.containsKey(i)) {
count = paths.get(i);
if (normalize)
str.append(i + 1 + ":"
+ form.format(count / n).replace(",", ".")
+ " ");
else
str.append(i + 1 + ":" + count + " ");
}
}
if (training) {
synchronized (train_file) {
train_file.append(str);
train_file.newLine();
}
} else if (validation) {
synchronized (validation_file) {
validation_file.append(str);
validation_file.newLine();
}
} else {
synchronized (test_file) {
test_file.append(str);
test_file.newLine();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}