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 小时前
pytest——Mark标记
开发语言·python·pytest
Dream of maid8 小时前
Python12(网络编程)
开发语言·网络·php
W23035765739 小时前
经典算法:最长上升子序列(LIS)深度解析 C++ 实现
开发语言·c++·算法
.Ashy.9 小时前
2026.4.11 蓝桥杯软件类C/C++ G组山东省赛 小记
c语言·c++·蓝桥杯
Y4090019 小时前
【多线程】线程安全(1)
java·开发语言·jvm
不爱吃炸鸡柳9 小时前
Python入门第一课:零基础认识Python + 环境搭建 + 基础语法精讲
开发语言·python
minji...10 小时前
Linux 线程同步与互斥(三) 生产者消费者模型,基于阻塞队列的生产者消费者模型的代码实现
linux·运维·服务器·开发语言·网络·c++·算法
Dxy123931021610 小时前
Python基于BERT的上下文纠错详解
开发语言·python·bert