• 概念格算法实现java


    import java.io.*;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    
    public class read1 {
        public static void main(String[] args) throws IOException{
            String file = "/home/ja/CADATA/mushroom_fp_threshold50.1";
            FileReader fr = new FileReader(new File(file));
            BufferedReader bf = new BufferedReader(fr);
            List<Map<List<String>,Integer>> list = new ArrayList<Map<List<String>,Integer>>();
            String line = null;
            while((line = bf.readLine()) != null){
                Map<List<String>,Integer> map = new HashMap<List<String>,Integer>();
                if(line.trim() != ""){
                    List<String> l = new ArrayList<String>();
                    String[] str = line.split(":",2);
                    String[] tmpstr = str[0].trim().split(" ");
                    for (String string : tmpstr) {
                        l.add(string.trim());
                    }
                    int tmp = Integer.parseInt(str[1].trim());
                    map.put(l,tmp);
                }
                list.add(map);
            }
            
            
            for(int i=0;i<list.size();i++){
                //System.out.println(list.get(i));
            }
            
            int sizes = list.get(list.size()-1).entrySet().iterator().next().getKey().size();
    
            List<List<Map<List<String>,Integer>>> result = new ArrayList<List<Map<List<String>,Integer>>>();
            
            int k = 1;
            
            while(k <= sizes){
                List<Map<List<String>,Integer>> tmp = new ArrayList<Map<List<String>,Integer>>();
                for(int j=0;j<list.size();j++){
                    if(list.get(j).entrySet().iterator().next().getKey().size() == k){
                        tmp.add(list.get(j));
                    }
                }
                k++;
                result.add(tmp);
            }
            
            for(int t=0;t<result.size()-1;t++){
                for(int j=0;j<result.get(t+1).size();j++){
                    for(int i=0;i<result.get(t).size();i++){
                        if(result.get(t+1).get(j).entrySet().iterator().next().getKey().containsAll(result.get(t).get(i).entrySet().iterator().next().getKey()) 
                                && result.get(t+1).get(j).entrySet().iterator().next().getValue() == result.get(t).get(i).entrySet().iterator().next().getValue()){
                            result.get(t).remove(i);
                            i--;
                        }
                        //System.out.println(result.get(0).get(i).entrySet().iterator().next().getKey() + ":" + result.get(0).get(i).entrySet().iterator().next().getValue());
                        //System.out.println(result.get(1).get(j).entrySet().iterator().next().getKey() + "\\" + result.get(1).get(j).entrySet().iterator().next().getValue());
                    }
                }
            }
            
            
            for(int i=0;i<result.size();i++){
                System.out.println(result.get(i).size() + "---" + result.get(i));
            }
            
            System.out.println();
        }
    }
  • 相关阅读:
    如何添加动画效果
    iQuery高版本不兼容旋转木马插件问题
    splice方法可以实现增删改功能
    swiper.js实现轮播图效果
    MySQL | 操作表数据
    MySQL | 高级查询
    MySQL | 基本查询
    MySQL | 表函数
    MySQL | 表约束
    MySQL | 操作表
  • 原文地址:https://www.cnblogs.com/wn19910213/p/3575045.html
Copyright © 2020-2023  润新知