MFC----Map使用。

快速去除重复字符串并统计重复次数

static map<string, int> word_count;  //存储GET容器 声明
static map<string, int>::iterator iter; //遍历链接迭代器

使用:

        //map去重统计操作  这里操作的
        string word;
        if (v1[1].size()!= NULL)
        word = v1[1].c_str();

        ++word_count[word]; //循环存进容器带排序  全自动58M数据8-10秒存完。

排序:

vector<pair<string, int>> counts(word_count.begin(), word_count.end());  //元素插入过程 需要先插入vectorsort;

(counts.begin(), counts.end(), CmpByValue());      //排序

工作笔记;

猜你喜欢

转载自blog.csdn.net/qq_42095701/article/details/90023409