当前位置: 首页>>代码示例>>Java>>正文


Java TIntIntHashMap.size方法代码示例

本文整理汇总了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);
				}
			}
			
		}
		
	}
	 
}
 
开发者ID:sisinflab,项目名称:lodreclib,代码行数:60,代码来源:ItemPathExtractorWorker.java

示例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();
        }
    }
 
开发者ID:sisinflab,项目名称:lodreclib,代码行数:66,代码来源:UserPathExtractorWorker.java


注:本文中的gnu.trove.map.hash.TIntIntHashMap.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。