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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:56:51+00:00 2026-06-13T20:56:51+00:00

I have a Tool struct that contains information about a tool retrieved from a

  • 0

I have a Tool struct that contains information about a tool retrieved from a database table, where at program start up all tools are retrieved.

struct Tool {
    const int            id;
    const std::string    name;
    const std::string    category;
    int                  outcomeID;
}

And I have a ToolManager class that maintains these Tools in a vector for now. What I’m struggling with is what container is best for storing these based on how I need to retrieve and display them.

Sometimes they need to be displayed in a table grouping tools by their outcomeID. Many times they are displayed in a tree structure by category and by only one or two outcomeID’s like so:

CategoryName1
    Tool_1
    Tool_3
CategoryName2
    Tool_5

I would rather not use Boost::multi_index (too complex for the nature of the project).
What is a simple, efficient way to store and retrieve these?

EDIT: To be clear, I need to be able store and look up these Tools by a combination of category or outcomeID.

  • 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-13T20:56:52+00:00Added an answer on June 13, 2026 at 8:56 pm

    One solution would be to have a container with permanent iterators (such as list) as your main storage, and auxiliary containers of iterators for fast retrieval:

    #include <list>
    #include <set>
    
    typedef std::list<Tool> container_type;
    typedef container_type::iterator iterator_type;
    
    struct outcome_cmp
    {
        bool operator<(iterator_type const & a, iterator_type const & b) const
        {
            return a->outcomeID < b->outcomeID;
        }
    };
    
    container_type tools;
    std::multi_set<iterator_type, outcome_cmp> outcome_index;
    
    // insert "x":
    auto it = tools.insert(tools.end(), x);
    outcome_index.insert(it);
    

    Now you can use the usual multiset iteration pattern to get the tools grouped by outcome ID.

    Similarly, you can make an ordering for category and name:

    #include <tuple>  // for std::tie and free lexicographic ordering
    
    struct cat_cmp
    {
        bool operator<(iterator_type const & a, iterator_type const & b) const
        {
            return std::tie(a->category, a->name) < std::tie(b->category, b->name);
        }
    };
    
    std::multiset<iterator_type, cat_cmp> cat_index;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tool that is setup to query our Clearquest Database to return
I have to code a Java program that will receive messages from network and
We have a tool that's provided to us from a 3rd party vendor, so
I have a tool that generates most (but not all) files that need to
We currently have a tool on our website that is created by JavaScript. The
I'd like to have a tool window in Visual Studio that allows me to
I have a rename tool that sets a folder directory, however I created some
We have a PHP tool which converts images from PSD into other formats by
I have a GUI tool that manages state sequences. One component is a class
So I have an app (tool) that uses .NET 3.0. When run on a

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.