C++ 标准模板库STL--Pair

cpp 复制代码
pair<size_t, size_t> 



#include <iostream>
#include <utility>
#include <cstdint>
#include <vector>

typedef std::pair<uint64_t, size_t> MapperKey;

int main(){
  std::vector<MapperKey> keys;

  MapperKey key1(123456789, 10);
  MapperKey key2(987654321, 20);
  MapperKey key3(555555555, 15);

  keys.push_back(key1);
  keys.push_back(key2);
  keys.push_back(key3);

  std::cout << "Iterating through MapperKeys:" << std::endl;
  for (const MapperKey& key : keys)
    {
      std::cout << "Key: " << key.first << ", " << key.second << std::endl;
    }

  return 0;
}

pair:用于存储两个 size_t 值组成的一对。

增:不能;

删:不能;

改:能,修改first和second的值;

查:能,修改first和second的值;

相关推荐
lsx2024065 分钟前
ionic 模态窗口:深入解析与最佳实践
开发语言
q***136113 分钟前
史上最厉害的Java进阶之路
java·开发语言
万事可爱^17 分钟前
GitHub爆火开源项目——RustScan深度拆解
c语言·开发语言·rust·开源·github·rustscan
ekkcole18 分钟前
java word转pdf工具类,兼容linux和windows服务器
开发语言·pdf·c#
G***669121 分钟前
算法设计模式:贪心与动态规划
算法·设计模式·动态规划
任子菲阳21 分钟前
学Java第四十五天——不可变集合、Stream流
java·开发语言·windows
CodeCraft Studio33 分钟前
Excel处理控件Aspose.Cells教程:使用Python从Excel工作表中删除数据透视表
开发语言·python·excel·aspose·aspose.cells·数据透视表
墨染点香36 分钟前
LeetCode 刷题【160. 相交链表】
算法·leetcode·链表
少睡点觉36 分钟前
LeetCode 238. 除自身以外数组的乘积 问题分析+解析
java·算法·leetcode
学IT的周星星1 小时前
SpringMVC请求参数的绑定
java·开发语言