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的值;

相关推荐
神明不懂浪漫15 分钟前
【第八章】多线程(一)
java·开发语言·经验分享·笔记
yiangL_1 小时前
1、Python 输入输出实验|print 与 input 人机交互实践
开发语言·python·人机交互
上海潭龙东海科技有限公司1 小时前
智慧堆场动态模型三维实时孪生重构智能管控
大数据·网络·数据库·算法·重构
一拳一个呆瓜2 小时前
【STL】头文件:<cmath>
c++·stl
草莓熊Lotso2 小时前
【C++ 基于微服务的即时通讯系统】ElasticSearch 用户数据管理实现
linux·数据库·c++·elasticsearch·微服务·架构
慧都产品智能化3 小时前
Qt 开发 CAD/CAM 工序表的隐性成本分析
c++·qt·qt5·qt6.3
山楂树の3 小时前
Java 泛型:泛型类、泛型方法、泛型接口与通配符
java·开发语言·笔记
阿庆_AI研发工程师3 小时前
Stanford CS336 Lecture 10:大语言模型推理与性能优化
算法
利威尔xu3 小时前
2026-11-18-Go接口幂等设计实战
开发语言·后端·golang
用户7341681035484 小时前
基于MindSpore的深度残差收缩网络程序
算法