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

  • SEARCH
  • Home
  • 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 9133449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:29:29+00:00 2026-06-17T08:29:29+00:00

On the weekend I will attend a programing competition and I would like to

  • 0

On the weekend I will attend a programing competition and I would like to know whether should I use std::vector or std::map? I would use them simply as arrays but I am confused which is the better(mostly speed for basic operations)?

I saw this pic on stackoverflow and I have no idea which is the main difference between these…

The picture suggest that vector is faster…
I really don’t know what to do pls help me! I need to use them only like arrays but with dynamical size…
Thanks in advance,

EDIT
I will probably get a 2D array of integers (for example a map of a city or a labirinth and I would be given some kind of problem that could be solved with graph-algorithms or dynamic programming), so the things I will need are: write, read specific cells of the “table”, search for specific values, and I guess thats all.
I heard that std::map won’t locate the full N*M sized table in the memory, but I will do it value by value… So is it true that it may use less memory?

Sorry for being so silly but I have never had any real teachers I learned all that I know on my on. I just started to learn about data structures(2-3 trees, red-black trees, binomial heaps, and so on…)

  • 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-06-17T08:29:30+00:00Added an answer on June 17, 2026 at 8:29 am

    I would like to know whether should I use std::vector or std::map?

    That completely depends on what you want/need to do. If you need to input 2 numbers from the user, add them and the display the result, there’s no point in using a vector or a map.

    However, if you need to store an array of objects (or primitives), std::vector is generally the way to go. If you need storage of keys and values, then that’s what std::map has been invented for. The question you asked is way too broad, so it’s practically very hard to answer it, but you may still get the idea.

    Also, you can get some inspiration about code that you should never try to replicate here.

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

Sidebar

Related Questions

This weekend I was working on a project and I needed to use a
I'm participating in a computer security competition this weekend and I'm trying to make
I will be deploying my web application this weekend on a testing server. I
right now this code works for tomorrow and next month - weekend use to
I am creating a calendar table for my warehouse. I will use this as
Over the weekend, another programmer added a file to a project and committed it
Over the weekend, for some reason, one of our servers has decided to start
Durning the weekend I'm trying to refresh my c++ skills and learn some c++11,
Over the weekend the SQL Server 2008 R2 (running on Windows Server 2008 R2)
In the weekend my phone chewed through $20 worth of credit by resending the

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.