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

相关推荐
hetao17338372 分钟前
2026-09-27~28 hetao1733837 的刷题记录
c++·算法
只睡四小时3 分钟前
JS 手写 D-pad 空间导航:电视端焦点引擎实战
android·开发语言·前端·javascript·ecmascript·hls·空间导航
2601_962218614 分钟前
C++的几种编译器的实现
开发语言·c++
Godspeed Zhao9 分钟前
现代智能雷达技术15——算法(1)
人工智能·算法·雷达
代码什么用12 分钟前
LeetCode-42. 接雨水
算法·leetcode
多弗朗皮卡丘15 分钟前
C++ stack和queue
开发语言·c++·deque·queue·stack·容器适配器
lengxuenong17 分钟前
枚举及其优化学习手册
c++·学习·算法·青少年编程
维克兜率天24 分钟前
【维克】弹性策略:用“乖离率“捕捉超跌反弹
android·开发语言·python·深度学习·kotlin·量化
小O的算法实验室31 分钟前
IEEE TAI,RoCo:基于角色的LLM协作实现自动启发式设计
算法
小范的技术工坊36 分钟前
大模型蒸馏
人工智能·算法·数据挖掘·大模型