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 6755139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:21:53+00:00 2026-05-26T13:21:53+00:00

These 4 containers, vector, list, map, unordered_map…are important b.c. they represent some of the

  • 0

These 4 containers, vector, list, map, unordered_map…are important b.c. they represent some of the most commonly used data structures. Internally they are represented as a dynamic array, double linked list, a searchable tree, and a hash.

   #include "c_arclib.cpp"
    using namespace std;
    int main()
      {
    /*
    Define - Vector, List, Map, Unordered_map
    */
      vector<int> vector_int;
      list<int> list_int;
      map<int,int> map_int;
      unordered_map<int, int> unordered_map_int; 
    /*
    Define Loop and Time 
    */
      int i,j,loop1=5, loop2=4294967;
      clock_t time_start,time_end,time_diff;
    /*
    Run Timing Test
    */
      for(j=0;j<loop1;j++)
        {
        time_start=clock();
        for(i=0;i<loop2;++i)
          {
          unordered_map_int.insert(pair<int,int>(rand(),rand()));
          /*
          map_int.insert(pair<int,int>(rand(),rand()));
          vector_int.push_back(rand());
          list_int.push_back(rand());
          */
          }
        time_end=clock();
        time_diff=time_end-time_start;
        cout << time_diff << endl;
        }
    /*
    Results
    Push / Insert
    map (insert)                    9500
    unorderd_map (insert)           3300
    list (push)                     2600
    vector (push)                   900
    */
  • 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-26T13:21:53+00:00Added an answer on May 26, 2026 at 1:21 pm

    I think you’re probably looking to just do this?

    cout << (double)(time_end - time_start) / CLOCKS_PER_SEC << endl;
    

    Also, there are more accurate timers than clock().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have two containers storing pointers to the same objects: std::list<Foo*> fooList; std::vector<Foo*>
I'm changing a vector to a list. Ive fixed all the errors except these
So there's list?, seq?, vector?, map? and so on to determine what type of
I have these container objects (let's call them Container) in a list. Each of
I have one std::list<> container and these threads: One writer thread which adds elements
Consider one has some user defined types, and containers of those types that are
I'm having a std::vector with elements of some class ClassA . Additionally I want
If I have a container ( vector , list , etc) where each element
I have a vector which contains a list of Hash maps in Clojure and
Dear All, I used a vector of vector, say vector<vector<int> > no_1_2 to store

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.