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

相关推荐
H H.3 小时前
Java企业级开发:从框架到工程化实战
java·开发语言·经验分享·其他·课程设计
Pniubi4 小时前
01背包类问题-力扣416.分割等和子集
算法·leetcode·职场和发展
吃我一窝jio14 小时前
Python与Go线程模型深度对比
java·开发语言·python
eggwyw15 小时前
C++ union 的一种妙用法
开发语言·c++
罗西的思考15 小时前
【轻量化复现大模型 / KIMI K3】MTP / EAGLE‑3 模块交互式演示
人工智能·深度学习·算法
ShineWinsu16 小时前
对于Qt:QHBoxLayout常见属性以及方法的解析
c++·qt·面试·gui·客户端·布局管理器·水平布局器
starzy199017 小时前
深入理解Scala隐式函数:自动类型转换
开发语言·后端·scala
小七在进步17 小时前
string的实现(1)
c++·笔记·visual studio
布莱克60519 小时前
Swift 循环与控制转移详解:从 for-in 到标签跳转
开发语言·ssh·swift·循环
kyle~19 小时前
模型预测控制(MPC)
算法·机器人·控制·传感器