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

相关推荐
lly20240611 小时前
Bootstrap 警告框
开发语言
2601_9491465311 小时前
C语言语音通知接口接入教程:如何使用C语言直接调用语音预警API
c语言·开发语言
你撅嘴真丑12 小时前
第九章-数字三角形
算法
曹牧12 小时前
Spring Boot:如何测试Java Controller中的POST请求?
java·开发语言
在路上看风景12 小时前
19. 成员初始化列表和初始化对象
c++
KYGALYX12 小时前
服务异步通信
开发语言·后端·微服务·ruby
uesowys12 小时前
Apache Spark算法开发指导-One-vs-Rest classifier
人工智能·算法·spark
zmzb010312 小时前
C++课后习题训练记录Day98
开发语言·c++
ValhallaCoder12 小时前
hot100-二叉树I
数据结构·python·算法·二叉树
董董灿是个攻城狮12 小时前
AI 视觉连载1:像素
算法