最全C++(15)——关联容器和海量数据查重_c+(2),2024年最新下血本买的

img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上C C++开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以戳这里获取

multiset<Student>set2;
set2.insert(Student(1, "wyl"));
set2.insert(Student(2, "yyz"));
set2.insert(Student(1, "wyl"));
for (auto it = set2.begin();it != set2.end();it++)
{
	cout << \*it << endl;
}
return 0;

}


\*\*总结:  
 1、单集合容器不允许关键字重复,多集合容器允许重复  
 2、在容器中不能修改元素  
 3、有序关联容器会进行排序,无序关联容器不会进行排序  
 \*\*


## map


map底层存放的是键值对[key,value]



struct std::pqir<int const,int>
{
int const key;
int value;
}

map1.insert(make_pair(1000, “wyl”));
map1.insert({ 1001,“wyl1” });
map1.insert(pair<int,string>(10, “we”));


map的下标运算符重载函数分为两步:  
 1、查询是否存在  
 2、如果不存在则插入一对键值对。  
 其余操作和set无差别



class Student
{
public:
Student(int id = 0, string name = nullptr)
:_id(id), _name(name)
{}
bool operator<(const Student &stu)const
{
return this->_id < stu._id;
}
private:
int _id;
string _name;
friend ostream& operator<<(ostream &out, const Student &stu);

};
ostream& operator<<(ostream &out, const Student &stu)
{
out << "id: " << stu._id << "name: " << stu._name << endl;
return out;
}
int main()
{
map<int, Student>map1;
map1.insert({ 1000,Student(1000,“wyl1”) });
map1.insert({ 1001,Student(1001,“wyl2”) });
map1.insert({ 1002,Student(1002,“wyl3”) });
map1.insert({ 1003,Student(1003,“wyl4”) });
cout << map1[1000] << endl;
auto it5 = map1.find(1000);
cout << it5->first<second << endl;
it5 = map1.begin();
for (;it5 != map1.end();it5++)
{
cout << “key:” << it5->first << “value:” << it5->second << endl;
}

unordered_map<int, string>map1;
map1.insert(make\_pair(1000, "wyl"));
map1.insert({ 1001,"wyl1" });
map1.insert(pair<int,string>(10, "we"));
//返回键值表的个数
cout << map1.size() << endl;
cout << map1[1000] << endl;
map1.erase(1001);
//operator[]
//1、查询
//2、如果key不存在,他会插入一对数据[key,string()]
map1[2000] = "王煜龙";
cout << map1[2000] << endl;
auto it2 = map1.find(1000);
cout << it2->first << it2->second << endl;
it2 = map1.begin();
for (;it2 != map1.end();it2++)
{
	cout << it2->first << ":" << it2->second << endl;
}
	return 0;

}


### 海量数据查重去重



#define SIZE 100
int main()
{
int arr[SIZE] = { 0 };
for (int i = 0;i < SIZE;++i)
{
arr[i] = rand() % 10;
}
unordered_map<int, int>map1;
for (int k : arr)
{
/*
auto it = map1.find(k);
if (it == map1.end())
{
map1.insert({ k,1 });
}
else
{
it->second++;
}
*/
map1[k]++;
}
for (const pair<int, int>&p : map1)
{

	if (p.second > 1)
	{
		cout << "key:" << p.first << "count:" << p.second << endl;
	}
	
}
auto it3 = map1.begin();
for (;it3 != map1.end();it3++)
{
	cout << "key:" << it3->first << "count:" << it3->second << endl;
}

//在上整数中去重
unordered_set<int>set;
for (int k : arr)
{
	set.insert(k);

}
for (int k : set)
{
	cout << k << " ";
}
return 0;

}








![img](https://img-blog.csdnimg.cn/img_convert/4a968530e9de5ac71976975a6fa6ead4.png)
![img](https://img-blog.csdnimg.cn/img_convert/34509b35b8c4548b2ea6bed9b75b6617.png)

**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化的资料的朋友,可以添加戳这里获取](https://bbs.csdn.net/topics/618668825)**


**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化的资料的朋友,可以添加戳这里获取](https://bbs.csdn.net/topics/618668825)**


**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值