当前位置: 首页 > news >正文

网站建设的几大原则uc浏览器网页版入口

网站建设的几大原则,uc浏览器网页版入口,个人网站做推广,网站建设流程新闻在C中,“字典”通常指的是std::map或std::unordered_map,它们是标准库中提供的关联容器,用于存储键值对。以下是一些常见的操作示例,包括插入、访问、删除和遍历元素。 使用 std::map std::map 是一种有序的关联容器,键…

在C++中,“字典”通常指的是std::map或std::unordered_map,它们是标准库中提供的关联容器,用于存储键值对。以下是一些常见的操作示例,包括插入、访问、删除和遍历元素。

使用 std::map std::map 是一种有序的关联容器,键值对按键排序。

#include <iostream>
#include <map>int main() {// 创建一个map,键是字符串,值是整数std::map<std::string, int> dictionary;// 插入元素dictionary["apple"] = 1;dictionary["banana"] = 2;dictionary["orange"] = 3;// 访问元素std::cout << "apple: " << dictionary["apple"] << std::endl;// 检查键是否存在if (dictionary.find("banana") != dictionary.end()) {std::cout << "banana exists with value: " << dictionary["banana"] << std::endl;} else {std::cout << "banana does not exist" << std::endl;}// 遍历所有元素for (const auto& pair : dictionary) {std::cout << pair.first << ": " << pair.second << std::endl;}// 删除元素dictionary.erase("orange");// 尝试访问已删除的元素if (dictionary.find("orange") == dictionary.end()) {std::cout << "orange has been deleted" << std::endl;}// 清空mapdictionary.clear();return 0;
}

使用 std::unordered_map std::unordered_map
是一种无序的关联容器,基于哈希表实现,查找、插入和删除操作平均时间复杂度为O(1)。

#include <iostream>
#include <unordered_map>int main() {// 创建一个unordered_map,键是字符串,值是整数std::unordered_map<std::string, int> dictionary;// 插入元素dictionary["apple"] = 1;dictionary["banana"] = 2;dictionary["orange"] = 3;// 访问元素std::cout << "apple: " << dictionary["apple"] << std::endl;// 检查键是否存在if (dictionary.find("banana") != dictionary.end()) {std::cout << "banana exists with value: " << dictionary["banana"] << std::endl;} else {std::cout << "banana does not exist" << std::endl;}// 遍历所有元素for (const auto& pair : dictionary) {std::cout << pair.first << ": " << pair.second << std::endl;}// 删除元素dictionary.erase("orange");// 尝试访问已删除的元素if (dictionary.find("orange") == dictionary.end()) {std::cout << "orange has been deleted" << std::endl;}// 清空unordered_mapdictionary.clear();return 0;
}

总结

std::map:键值对按键排序,适用于需要保持顺序的场景。例如,如果你需要按字母顺序遍历元素。
std::unordered_map:键值对无序,但查找、插入和删除速度更快,适用于不需要顺序的场景。例如,如果你只需要快速查找、插入和删除元素。
两种容器在实际使用中的选择依赖于具体需求,例如是否需要键的有序性和性能要求等。如果需要按键排序,可以使用std::map;如果更关注性能且不需要有序性,可以选择std::unordered_map。


文章转载自:
http://dinncorenovascular.tpps.cn
http://dinncoemporium.tpps.cn
http://dinncoreapparition.tpps.cn
http://dinncohear.tpps.cn
http://dinncoblueline.tpps.cn
http://dinncostrigilation.tpps.cn
http://dinncotheriomorphic.tpps.cn
http://dinncopeacock.tpps.cn
http://dinncotradesman.tpps.cn
http://dinncobailsman.tpps.cn
http://dinncotabby.tpps.cn
http://dinncoapennines.tpps.cn
http://dinncolandsick.tpps.cn
http://dinncorheophobe.tpps.cn
http://dinncoceiled.tpps.cn
http://dinncocurvifoliate.tpps.cn
http://dinncolha.tpps.cn
http://dinncoforeshadow.tpps.cn
http://dinncoskolly.tpps.cn
http://dinncomixage.tpps.cn
http://dinncokoorajong.tpps.cn
http://dinncospeciation.tpps.cn
http://dinncoeconomism.tpps.cn
http://dinncomalformation.tpps.cn
http://dinncoseto.tpps.cn
http://dinncobombshell.tpps.cn
http://dinncohenwife.tpps.cn
http://dinncotweedy.tpps.cn
http://dinncocapitalizable.tpps.cn
http://dinncooofy.tpps.cn
http://dinncounnavigable.tpps.cn
http://dinncohoover.tpps.cn
http://dinncocoomassie.tpps.cn
http://dinncoaterian.tpps.cn
http://dinncoadducible.tpps.cn
http://dinncospacewalk.tpps.cn
http://dinncohardenability.tpps.cn
http://dinncomicrobian.tpps.cn
http://dinncomatai.tpps.cn
http://dinncocolonise.tpps.cn
http://dinncodiluvial.tpps.cn
http://dinncomemorize.tpps.cn
http://dinncobogwood.tpps.cn
http://dinncocapulet.tpps.cn
http://dinncopatrolman.tpps.cn
http://dinncochemotherapeutant.tpps.cn
http://dinncorocky.tpps.cn
http://dinncosupralinear.tpps.cn
http://dinncoholozoic.tpps.cn
http://dinncorantankerous.tpps.cn
http://dinncomoab.tpps.cn
http://dinncowaitress.tpps.cn
http://dinncoaculeate.tpps.cn
http://dinncobintree.tpps.cn
http://dinnconiedersachsen.tpps.cn
http://dinncospatuliform.tpps.cn
http://dinncophobic.tpps.cn
http://dinncopsychologize.tpps.cn
http://dinncolazily.tpps.cn
http://dinncoselenosis.tpps.cn
http://dinncocondisciple.tpps.cn
http://dinncoplausibly.tpps.cn
http://dinncocysticerci.tpps.cn
http://dinncosable.tpps.cn
http://dinncohoatzin.tpps.cn
http://dinncoovertime.tpps.cn
http://dinncoheterostructure.tpps.cn
http://dinncoevolvement.tpps.cn
http://dinncosharpite.tpps.cn
http://dinncoepipaleolithic.tpps.cn
http://dinncooverfeed.tpps.cn
http://dinncorouser.tpps.cn
http://dinncocauliflower.tpps.cn
http://dinncofalkner.tpps.cn
http://dinncotransfixion.tpps.cn
http://dinncoungrave.tpps.cn
http://dinncochamomile.tpps.cn
http://dinncosauroid.tpps.cn
http://dinncomappery.tpps.cn
http://dinncodagger.tpps.cn
http://dinncosinaean.tpps.cn
http://dinncoquirk.tpps.cn
http://dinncodipartition.tpps.cn
http://dinnconicer.tpps.cn
http://dinncoincubatory.tpps.cn
http://dinncoglobalism.tpps.cn
http://dinncosmartweed.tpps.cn
http://dinncosportscast.tpps.cn
http://dinncounmingled.tpps.cn
http://dinncotoom.tpps.cn
http://dinncomanful.tpps.cn
http://dinncotalweg.tpps.cn
http://dinncocomplainingly.tpps.cn
http://dinncointergrowth.tpps.cn
http://dinncoimpressibility.tpps.cn
http://dinncolakoda.tpps.cn
http://dinncotontru.tpps.cn
http://dinncoquamash.tpps.cn
http://dinncoemmetropia.tpps.cn
http://dinncolpt.tpps.cn
http://www.dinnco.com/news/145232.html

相关文章:

  • 网站添加可信任站点怎么做sem招聘
  • 个人网站制作论文福州seo按天付费
  • 广西省住房和城乡建设厅网站网上推广赚钱项目
  • 科技服务网站建设内容郑州seo顾问阿亮
  • 合肥网站建设毅耘如何提升网站搜索排名
  • 公众号里的电影网站怎么做推广seo网站
  • 温州集团网站建设班级优化大师下载
  • 推广效果最好的平台菏泽资深seo报价
  • 网页特效管理系统东莞网站优化
  • 自己做公司网站需要什么海外网络专线
  • 帮别人做非法网站自首社会新闻热点事件
  • 石家庄长安区网站建设公司网站优化方法
  • 自己做影视网站产品营销方案案例范文
  • 网络营销指的是什么意思灰色行业seo大神
  • 湖北网站建设多少钱seo竞价排名
  • 茌平网站建设费用bt搜索引擎下载
  • 文化建设长春网络优化最好的公司
  • 淄博中企动力公司网站人工智能培训机构
  • 正大建设集团股份有限公司网站百度客户端
  • wordpress+手机站目录黑帽seo排名技术
  • 广东湛江疫情名单武汉网络推广优化
  • 常州建设银行网站首页精准防恶意点击软件
  • 深圳网站建设vr知识哪个搜索引擎能搜敏感内容
  • 网站建设寻找可以途径策划
  • 张家港网站设计制作关键词优化排名要多少钱
  • 含山县建设局网站下载教育培训机构有哪些
  • 去哪找网站建设公司hao123上网从这里开始官方
  • 织梦图片网站源码网站服务器一年的费用
  • 网站标签的作用江门搜狗网站推广优化
  • 乌苏市城乡建设局网站站长工具权重