Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6021515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:43:26+00:00 2026-05-23T03:43:26+00:00

We are trying to use the std::deque erase member function. The return value of

  • 0

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);
   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:43:28+00:00Added an answer on May 23, 2026 at 3:43 am

    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::size is O(1)

    #include <iostream>
    #include <deque>
    using namespace std;
    
    int main ()
    {
      unsigned int i;
      deque<unsigned int> mydeque;
    
      // set some values (from 1 to 10)
      for (i=1; i<=10; i++) mydeque.push_back(i);
    
      cout << "\nmydeque contains:"<<mydeque.size();
    
      // erase the 6th element
      mydeque.erase (mydeque.begin()+5);
    
      // erase the first 3 elements:
      mydeque.erase (mydeque.begin(),mydeque.begin()+3);
    
      //Total Elements erased = 4
    
      cout << "\nNow mydeque contains:"<<mydeque.size();
    
      return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying use std::copy to copy from two different iterator. But during course
I'm trying to use a std::vector<>::const_iterator and I get an 'access violation' crash. It
I'm trying to use boost::bind with the std::sort function. I want to bind sort
I'm trying to use std::string instead of char* whenever possible, but I worry I
I'm trying to use templates to get std:list of items, where each item has
I'm trying to use openmp to multithread a loop through std::set. When I write
I'm trying to use stl algorithm for_each without proliferating templates throughout my code. std::for_each
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
Trying to use an excpetion class which could provide location reference for XML parsing,
I have a C++ class where I'm trying to use std::bind1st to bind a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.