Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我将 C++ 中的两个列表迭代器与 say 进行比较时operator<,我是否会获得 O(n) 性能,因为我们必须遍历整个列表以查看哪个迭代器在前面?
operator<
还是因为我的编译器做了一些聪明的事情而获得了 O(1) 的性能?
您会收到编译错误,因为list迭代器只是BidirectionalIterators,因此不支持operator<.
list
BidirectionalIterator