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

相关推荐
鳄鱼儿13 分钟前
密码算法的OID查阅
算法
ModestCoder_20 分钟前
ROS Bag与导航数据集技术指南
开发语言·人工智能·自然语言处理·机器人·具身智能
卡提西亚23 分钟前
C++笔记-34-map/multimap容器
开发语言·c++·笔记
lxh011343 分钟前
螺旋数组题解
前端·算法·js
2***B44944 分钟前
C++在金融中的QuantLibXL
开发语言·c++·金融
A***07171 小时前
C++在游戏中的阴影渲染
开发语言·c++·游戏
2401_837088501 小时前
Redisson的multilock原理
java·开发语言
合作小小程序员小小店1 小时前
桌面开发,在线%超市销售管理%系统,基于vs2022,c#,winform,sql server数据
开发语言·数据库·microsoft·c#
czlczl200209251 小时前
算法:二叉树的公共祖先
算法