C++ STL 中的 multimap find()

28 Aug 2024 | 5 分钟阅读

众所周知,C++ 编程语言有许多内置函数,可帮助我们避免编写冗长的代码行。其中一个函数是 C++ 编程语言丰富库(标准模板库 (STL))中提供的 multimap find 函数。它将帮助我们返回一个迭代器,该迭代器引用或指向我们创建的长或短 multimap 中包含数据遍历的键的位置。如果您有了解所有基本数据值的不同目标,那么您可以参考 C++ 编程语言丰富库(标准模板库 (STL))中可用的 equal range 函数。

C++ 中的 Multimap

输出

The multimap gquiz1 is : 
	KEY	ELEMENT
	1	40
	2	30
3	60
	6	50
	6	10


Multimap quiz1 after adding the extra elements is : 
	key	element
	1	40
	2	30
	3	60
	4	50
	5	10
	6	50
	6	10


The multimap gquiz2 after assignment from gquiz1 is : 
	KEY	ELEMENT
	1	40
	2	30
	3	60
	4	50
	5	10
	6	50
	6	10


 quiz2 after the removal of elements less than key = 3 : 
	 key 	 element 
	3	60
	4	50
	5	10
	6	50
	6	10

 quiz 2.erase(4) : 1 removed 
	key	element
	3	60
	5	10
	6	50
	6	10

the quiz1.lower bound (5) : 	key = 5		element = 10
the quiz1.upper bound (5) : 	KEY = 6		element = 50

C++ STL 中的 multimap find()

语法

C++ 代码

输出

The elements from position 3 in multimap are : 
Key	elements : 
31	210