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

相关推荐
赵广陆8 分钟前
企业实战:Markdown图片检索
android·java·开发语言
C++、Java和Python的菜鸟9 分钟前
第3章 从0开始用若依
java·开发语言
wabs66610 分钟前
关于字符串【力扣344.反转字符串的思考】
数据结构·算法·leetcode
夜雪一千35 分钟前
Python 如何实现 SHA 加密?SHA1 / SHA256 / SHA512 实战教程
开发语言·python
王老师青少年编程44 分钟前
2021年CSP-J初赛真题及答案解析(完善程序2)
c++·真题·csp-j·答案·csp·初赛·信奥赛
有点。1 小时前
C++二叉树(一)
开发语言·数据结构·c++
民乐团扒谱机1 小时前
【微实验】谐波乘积谱(HPS)算法深度解析:原理、数学与代码实现
开发语言·人工智能·python·算法·语音识别·音乐
Nil2081 小时前
leetcode 73矩阵置0
算法·leetcode·矩阵
报错小能手1 小时前
Go 语言结构 基础语法
开发语言·后端·golang
Lazionr1 小时前
stack与queue:底层实现与容器适配器
开发语言·数据结构·c++