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.
O(n) 未満の複雑さで multiset 内の 2 つのイテレータ間の距離を見つけることができますか? イテレータヘッダーで提供される std::distance() 関数を使用しようとしました。ただし、その内部実装はマルチセット イテレータの O(n) です。
multiset::iteratorRandomAccessIterator ではなく BidirectionalIterator をモデル化するためstd::distance、定数ではなく線形である必要があるだけです。
multiset::iterator
std::distance