We are trying to use the std::deque erase member function. The return value of the std::deque erase(iterator) member function is a A random access iterator pointing to the new location of the element that followed the last element erased by the function call, which is the container end if the operation erased the last element in the sequence.
We were wondering whether it is possible to efficiently check whether STL std::deque erase succeded. Thank you. An excerpt of our code is shown below:
typedef std::multimap<char *,Range>::const_iterator I;
std::pair<I,I> b = mmultimap.equal_range(TmpPrevMapPtr);
for (I i=b.first; i != b.second; ++i){
std::deque<Range>::iterator iter;
std::deque<Range>::iterator it;
iter = std::lower_bound(ranges_type.begin(),ranges_type.end(),i->second);
if (iter != ranges_type.end() && !(i->second < *iter)){
it = ranges_type.erase(iter);
}
}
Check if the size of dequeue decreases by the number of elements you erased.
With regards to the concern about performance, Time Complexity for
dequeue::sizeisO(1)