c++ - binary search a std:map -


using c++, if have n integers in std::map, possible efficiently search largest element smaller k in std::map ?

for example have {1, 3, 5, 6} , k 4 returned value should 3

i know std::map can search in log(n), if exact match.

use lower_bound , decrement returned iterator one.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -