一、需求
假设下面需求
1.字符串"1233214" -> "4"
2.字符串数组{ "1","2","3","3","2","1","4" } -> { "4" }
二、测试例子
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
// 去重复获取独立部分
// 1.字符串"1233214" -> "4"
// 2.字符串数组{ "1","2","3","3","2","1","4" } -> { "4" }
template <typename MajorType, typename MinorType>
MajorType removeRepeat(MajorType& src)
{
MajorType result_vec = MajorType();
if (src.empty())
return result_vec;
const int _ONE = 1;
std::map<MinorType, int> tmp_map;
for (auto itor = src.begin();
itor != src.end(); ++itor) {
++tmp_map[*itor];
}
for (auto itor = tmp_map.begin();
itor != tmp