练习
12.27
这个程序已经可以完成论文所作的功能了
class QueryResult {
//懒得重复写,所以使用类型别名
using str_vec_ptr = std::shared_ptr<vector<string>>;
using str_set_map_ptr = std::shared_ptr<map<string, set<size_t>>>;
using str_map_ptr = std::shared_ptr<map<string, size_t>>;
friend ostream& print(ostream& out, const QueryResult& result);
public:
QueryResult(string word,str_vec_ptr p1,str_set_map_ptr p2,str_map_ptr p3):query_word(word),text_content(p1),word_to_line_set_map(p2),word_count_map(p3) {
}
private:
//不使用类内初始化,使用TextQuery传入的参数进行初始化
str_vec_ptr text_content;
str_set_map_ptr word_to_line_set_map;
str_map_ptr word_count_map;
string query_word;
};
class TextQuery {
public:
//默认有50行
TextQuery(ifstream& ifile) {<