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

相关推荐
感哥17 分钟前
C++ std::set
c++
Fanxt_Ja44 分钟前
【LeetCode】算法详解#15 ---环形链表II
数据结构·算法·leetcode·链表
侃侃_天下44 分钟前
最终的信号类
开发语言·c++·算法
茉莉玫瑰花茶1 小时前
算法 --- 字符串
算法
博笙困了1 小时前
AcWing学习——差分
c++·算法
NAGNIP1 小时前
认识 Unsloth 框架:大模型高效微调的利器
算法
NAGNIP1 小时前
大模型微调框架之LLaMA Factory
算法
echoarts1 小时前
Rayon Rust中的数据并行库入门教程
开发语言·其他·算法·rust
Python技术极客1 小时前
一款超好用的 Python 交互式可视化工具,强烈推荐~
算法
徐小夕1 小时前
花了一天时间,开源了一套精美且支持复杂操作的表格编辑器tablejs
前端·算法·github