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

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