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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:02:39+00:00 2026-06-01T00:02:39+00:00

I have a table that is accessed by row and column, where those two

  • 0

I have a table that is accessed by row and column, where those two are not integral. They will, however be unique and taken from the same set. The table will need to be expanded, but always from the end. Removal may be necessary from the middle, but is not a priority.

I am currently testing 2 approaches:

map<Key, int> headers;
vector<vector<Value> > table;

Or:

map<Key, map<Key, Value> > table;

Which is going to be more appropriate? I am also open to new suggestions.

Examples showing basic usage (though both very much oversimplified) are here and here.

  • 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-01T00:02:41+00:00Added an answer on June 1, 2026 at 12:02 am

    It all depends on how this structure is going to be used: How densely populated the table will be, how efficient various operations have to be, how big the payload type (Value) will be, etc.

    Your first approach (vector of vectors, with a map to translate indices) is a dense representation: Every value is stored explicitly in the table. If vectors grow by a factor of L, then the total allocation excess for the data proper can go up to L^2. For example, if L == 1.25, you may end up over 50% excess storage; if sizeof(Value) is large or if your table is large, that may be prohibitive. Also expanding the table may occasionally be quite expensive (when the vectors must be reallocated).

    Your second approach (map of maps) is potentially sparse. However, if all table (row, column) pairs are accessed, it will get dense. Also, the book-keeping information for maps is a bit larger than for vectors. So for small Value sizes, the vector of vectors approach might be more space-efficient. If most of your table will be populated by “default” values, then you might improve things by distinguishing between read and write access to the table: A read for a value could perform a “find” and return a synthesized default value if notable entry was found.

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

Sidebar

Related Questions

I have a SQL table that will be accessed by two console apps (.NET).
I have a lookup table that should be accessed by two separate key values.
I have a table and every row will have an ID , Date ,
In a table, I have an ID column, that is an Identity int. How
I have a settings table in a database that is accessed through Entity Framework
I have the option to use a single table that will expand upwards of
I have table that I insert data with following query (from c# code): INSERT
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a table that got into the db_owner schema, and I need it
I have a table that contains tasks and I want to give these an

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.