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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:23:11+00:00 2026-05-13T18:23:11+00:00

Greetings code-gurus! I am writing an algorithm that connects, for instance node_A of Region_A

  • 0

Greetings code-gurus!

I am writing an algorithm that connects, for instance node_A of Region_A with node_D of Region_D. (node_A and node_D are just integers). There could be 100k+ such nodes.

Assume that the line segment between A and D passes through a number of other regions, B, C, Z . There will be a maximum of 20 regions in between these two nodes.

Each region has its own properties that may vary according to the connection A-D. I want to access these at a later point of time.

I am looking for a good data structure (perhaps an STL container) that can hold this information for a particular connection.

For example, for connection A – D I want to store :

node_A, 
node_D, 
crosssectional area (computed elsewhere) , 
regionB, 
regionB_thickness, 
regionB other properties, 
regionC, ....

The data can be double , int , string and could also be an array /vector etc.

  1. First I considered creating structs or classes for regionB, regionC etc .
    But, for each connection A-D, certain properties like thickness of the region through which this connection passes are different.
    There will only be 3 or 4 different things I need to store pertaining to a region.
    Which data structure should I consider here (any STL container like vector?) Could you please suggest one? (would appreciate a code snippet)

  2. To access a connection between nodes A-D, I want to make use of int node_A (an index).
    This probably means I need to use a hashmap or similar data structure.
    Can anyone please suggest a good data structure in C++ that can efficiently
    hold this sort of data for connection A -D described above? (would appreciate a code snippet)

thank you!

UPDATE
for some reasons, I can not make use of pkgs like boost. So want to know if I can use any libraries from STL

  • 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-13T18:23:11+00:00Added an answer on May 13, 2026 at 6:23 pm

    You should try to group stuff together when you can. You can group the information on each region together with something like the following:

    class Region_Info {
      Region *ptr;
      int thickness;
      // Put other properties here.
    };
    

    Then, you can more easily create a data structure for your line segment, maybe something like the following:

    class Line_Segment {
      int node_A;
      int node_D;
      int crosssectional_area;
      std::list<Region_Info>;
    };
    

    If you are limited to only 20 regions, then a list should work fine. A vector is also fine if you would prefer.

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

Sidebar

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.