I was wondering if walking on Set (from STL) is very costly? I need sorted array and that's the only reason I used Set. Should I create my own sorted list or walking on Set is "ok"?
No, it is not costly (asymptotically). According to C++ standard it's done in linear time because each step takes constant time (amortized).
Although walking through actual sorted array (e.g std::vector or plain C array) may be a little bit faster due to lower constant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With