T
Thomas Kowalski
Hi,
I have an sorted vector<double> v and want to insert a new double val.
What I need is the position the val have been inserted at in the
vector. My basic idea is something like this (pseudo-code) :
it = lower_bound(v.begin(), v.end(), greater(val));
v.insert(it,val);
size_t pos = it - v.begin();
Does anyone know whether lower_bound finds the first occurrence of an
object in a vector in O(log(n)) in case the values in the vector are
unique?
Are there any better ideas how to do it easy and most important fast?
Thanks in advance,
Thomas Kowalski
I have an sorted vector<double> v and want to insert a new double val.
What I need is the position the val have been inserted at in the
vector. My basic idea is something like this (pseudo-code) :
it = lower_bound(v.begin(), v.end(), greater(val));
v.insert(it,val);
size_t pos = it - v.begin();
Does anyone know whether lower_bound finds the first occurrence of an
object in a vector in O(log(n)) in case the values in the vector are
unique?
Are there any better ideas how to do it easy and most important fast?
Thanks in advance,
Thomas Kowalski