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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:33:43+00:00 2026-05-23T22:33:43+00:00

I want to design a data structure with the following properties: Accessible as a

  • 0

I want to design a data structure with the following properties:

  1. Accessible as a single array of some type say T. For example s[i].
  2. Ability to access named ranges in it. For example s.GoodObjects[i], s.BadObjects[j].
  3. Iterate over it as a whole (STL algorithms etc.).
  4. Converting the name-index to index in the whole array. Here the interface is a good question too.

Also the desired behaviour would be the ability to

  1. I really want ranges names to be checked at compile time, not some string-named ranges, but C++ identifier-named.
  2. Add or remove elements to subarrays. s.BadObjects.push_back(yourMom).
  3. Implement it without using macros, just good C++ and templates, but readability of usages is of course the #1 priority.
  4. Possibly range arrays could have element type of a pointer to derived class where T is a pointer to base class.

So, how would you design such a structure?

Edit

Looks like I haven’t stated it too explicitly, but the 4th requirement (the first list) is actually very important one.
Maybe a more general question would be as follows: how to properly design an indexed collection of objects of different types (having a common superclass) with easy indexed access to objects of particular subtype? So, having a through index is a neccesity.

One can assume that all the types are known at compile-time, and amount of every particular object in the whole array is constant (from config file).

  • 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-23T22:33:44+00:00Added an answer on May 23, 2026 at 10:33 pm

    If you really want to to this, you could have a class storing several std::vectors and then supply an operator[] for the class itself that redirects into these vectors, perhaps depending on their respective size.

    While you’re at it, the outer class could also provide begin() and end() to allow iteration over the entire dataset.

    I doubt though that the good-design tag is applicable here. 🙂

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

Sidebar

Related Questions

I want to manage a n-label comment system and design a data base structure
Hi:I want to design a structure for letting sensor data ( 3 float values
I'm trying to design a class structure with the following: Container class which holds
Im want to create a data structure for using within my MVC3 application. The
I want to create only the collections structure. i.e. Say Products collection contains a
I want a textual interface for some structured data that I want to put
I was asked to design a data structure for the meeting schedules and after
I want design my startup screen with progress bar. But I don't how to
That's my question, I want design all the interface of my application within an
I want to design a rich text area for iPhone where user can enter

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.