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

相关推荐
fengenrong8 小时前
20260324
c++·算法
qq_416018728 小时前
设计模式在C++中的实现
开发语言·c++·算法
Evand J8 小时前
【MATLAB教程】在matlab中,gscatter和scatter两个命令的区别
开发语言·matlab·教程·绘图·命令·教学
倾心琴心8 小时前
【agent辅助pcb routing coding学习】实践9 CU GR 代码 算法学习
算法·agent·pcb·eda·routing
数据智能老司机8 小时前
谷歌 TurboQuant 深度拆解:LLM 内存压缩 6 倍、推理加速 8 倍、零精度损失,它是怎么做到的?
算法
2301_776508728 小时前
C++与机器学习框架
开发语言·c++·算法
ALex_zry8 小时前
现代C++设计模式实战:从AIDC项目看工业级代码架构
c++·设计模式·架构
Albertbreak8 小时前
STL容器内部实现剖析
开发语言·c++·算法
chudonghao8 小时前
[UE学习笔记][基于源码] 理解 Gameplay
c++·笔记·学习·ue5
CoovallyAIHub8 小时前
AAAI 2026 | AnoStyler:文本驱动风格迁移实现零样本异常图像生成,轻量高效(附代码)
算法·架构·github