Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time Complexity of std::multimap::equal_range

Good afternoon, I am wondering what the time complexity of std::multimap::equal_range is? Is it Big-O(n) or BIG-0(log n). I remember reading that the time complexity of std::multimap::erase "is logarithmic plus linear time for the length of the sequence being removed." <http://frank.mtsu.edu/~csjudy/STL/Multimap.html>

like image 765
Frank Avatar asked May 12 '11 18:05

Frank


2 Answers

C++03 standard, Table 69 ("Associative container requirements") in 23.1.2 says that equal_range has logarithmic complexity.

like image 143
Steve Jessop Avatar answered Sep 18 '22 22:09

Steve Jessop


equal_range is an O(log n) operation returning the pair of lower_bound and upper_bound.

This means it will return an iterator range starting with the first key that is greater-than or equal-to the search key and ending with the first key that is greater than the search key.

like image 40
Cory Nelson Avatar answered Sep 20 '22 22:09

Cory Nelson