显然;-)标准容器提供某种形式的保证.
什么类型的保证以及不同类型的容器之间究竟有什么区别?
Container Types:
================
Container:
Forward Container
Reverse Container
Random Access Container
Sequence
Front Insert Sequence
Back Insert Sequence
Associative Container
Simple Associative Container
Pair Associative Container
Sorted Associative Container
Multiple Associative Container
Container Types mapped to Standard Containers
=============================================
std::vector: Sequence Back Sequence Forward/Reverse/Random Container
std::deque: Sequence Front/Back Sequence Forward/Reverse/Random Container
std::list: Sequence Front/Back Sequence Forward/Reverse Container
std::set: Sorted/Simple/Unique Associative Container Forward Container
std::map: Sorted/Pair/Unique Associative Container Forward Container
std::multiset: Sorted/Simple/Multiple Associative Container …Run Code Online (Sandbox Code Playgroud) 可能重复:
STL类似容器,具有O(1)性能.
我一直认为std :: map是一个散列列表.在那种情况下,不应该查找O(1).文档说它是O(logn).STL中适当的数据结构是什么,模拟散列映射最好用O(1)插入和查找.