2012-02-14 73 views

回答

4

你能做的最好是使用:

std::map::upper_bound()
std::map::lower_bound()
獲得迭代器位置,其中關鍵是大於或大於或等於特定鍵值。

+4

值得注意的是,如果您將'lower_bound'的結果作爲提示傳遞給'insert',那麼您將獲得後者的恆定時間性能。 – 2012-02-14 07:30:11