如何实现C ++ multimap容器? [英] How is the C++ multimap container implemented?
问题描述
例如,使用动态数组来实现C ++向量,其中每个元素使用连续的内存空间。
For example a C++ vector is implemented using a dynamic array where each element uses consecutive memory spaces.
我知道C ++ multimap是一对多的关系,但是什么是内部结构?
I know that a C++ multimap is a one to many relationship but what is the internal structure?
推荐答案
C ++标准没有定义标准容器的实现方式,像您为向量所说的那样。
The C++ standard does not define how the standard containers should be implemented, it only gives certain constraints like the one you say for vectors.
多重映射具有一定的运行时复杂性(对于有趣的操作,是O(lg n))和其他保证,可以实现为红黑树。这是它们在GNU标准C ++库中的实现方式。
multimaps have certain runtime complexity (O(lg n) for the interesting operations) and other guarantees, and can be implemented as red-black trees. This is how they are implemented in the GNU standard C++ library.
这篇关于如何实现C ++ multimap容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!