STL映射和多图 [英] STL Map and Multimap

查看:101
本文介绍了STL映射和多图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我对地图和多图有一些疑问.

Hi All,

I have some questions in mind about map and multimap.

    • 我知道STL将高度平衡二进制搜索树用于MAP实现,但实际上是用于多图的.
  • 多图也可以在每个节点的列表中使用相同的内容作为键.我是对的吗?
  • 我如何在树状结构(如地图和多图)中提供迭代器功能,就像在树状结构中一样,很难依次遍历数据. li>



如果可以回答这些问题,将非常有帮助.

BR,
Akash



It will be very helpful if these questions can be answered.

BR,
Akash

推荐答案

1)看一下标准库的编译器版本的源代码.

话虽这么说,只是因为特定版本的标准库会以一种方式做事并不意味着其他人就无法做一些根本不同的事情.

2)如果某物具有某种比较运算符,通常可以将其用作地图或多图的键.

3)使用内置的迭代器-不要尝试自己做饭

干杯,

1) Have a look in the source code of your compiler''s version of the standard library.

Having said that just because a particular version of the standard library does things one way doesn''t mean that others can''t do something radically different.

2) If something has a comparison operator of some sort it can usually be used as the key of a map or multimap.

3) Use the built in iterators - don''t try and cook your own

Cheers,

Ash


这篇关于STL映射和多图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆