當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。