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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:53:41+00:00 2026-05-15T16:53:41+00:00

I was wondering if it was faster to have a std::vector<std::vector<double>> where the nested

  • 0

I was wondering if it was faster to have a std::vector<std::vector<double>>where the nested vector always has 2 elements, or is it faster to have a std::vector<MyPoint>where MyPoint is defined like:

struct MyPoint {
  double Point[2];
};

Thanks

  • 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-15T16:53:42+00:00Added an answer on May 15, 2026 at 4:53 pm

    The vector<MyPoint> is preferable, because MyPoint is likely:

    1. to be smaller than vector<double> (you can check this with sizeof), and/or
    2. to make fewer allocations. A vector object itself is small, but generally points to data on the heap. It’s possible for small vectors to be optimised to avoid the extra allocation by embedding the data in the vector object, but don’t count on that, hence
    3. to have lower overhead of initialization, destruction, and copying.

    For example on my 32bit gcc, std::vector<double> has size 12, while MyPoint has size 16, but the vector makes the extra allocation. On a 64bit implementation, MyPoint will almost certainly be the same size, but std::vector will probably be bigger.

    Also, a vector represents a variable-sized, ordered container using contiguous memory. So it’s arguably overkill for a size-2 array, since the use of a vector introduces the possibility that the size might change.

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

Sidebar

Related Questions

Just wondering weather its faster, if you have lots (~several hundred to a thousand)
I am wondering which way would end up being faster, selecting elements by: $('element[href=#my_link]');
I have this, but I was wondering if there is a faster way: URL
I would like to know whats faster. Help me out. I have a variable
This is something I have been wondering about. Is it faster to have MySQL
I am wondering whether nested if is better than AND statement. I have a
i have technical wondering here guys , switch statement performs faster ,that thing i
I have been wondering if there is a more concise and faster way to
I wondering if there is a faster (GPU time) way to draw a full-screen
Wondering if someone could help me. I have next to no knowledge with Ajax,

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.