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

相关推荐
金山几座2 分钟前
C#学习记录-事件
开发语言·学习·c#
xixixiLucky9 分钟前
编程入门算法题---小明爬楼梯求爬n层台阶一共多少种方法
算法
剑锋所指,所向披靡!22 分钟前
数据结构之线性表
数据结构·算法
小杍随笔25 分钟前
【Rust 语言编程知识与应用:基础数据类型详解】
开发语言·后端·rust
Yupureki30 分钟前
《MySQL数据库基础》1. 数据库基础
c语言·开发语言·数据库·c++·mysql·oracle·github
enmouhuadou1 小时前
快速运行matlab仿真方法
开发语言·matlab
m0_706653231 小时前
使用C-Free进行浮点变量的四则运算指南
c语言·开发语言
汉克老师2 小时前
GESP2026年3月认证C++二级( 第二部分判断题(1-10))
c++·gesp三级·gesp3级
m0_672703312 小时前
上机练习第49天
数据结构·算法
样例过了就是过了2 小时前
LeetCode热题100 N 皇后
数据结构·c++·算法·leetcode·dfs·深度优先遍历