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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:00:06+00:00 2026-05-30T15:00:06+00:00

What is an appropriate container for compound index that allows ignoring the sub-index at

  • 0

What is an appropriate container for compound index that allows ignoring the sub-index at lookup? It should not use more resources than a container without this feature.

F.e. given the index

struct index_t
{
    index_t(unsigned key_, unsigned subkey_)
        :   key(key_)
        ,   subkey(subkey_)
    {}
    unsigned key;
    unsigned subkey;
};

and inserting

index_t(1,11)
index_t(2,21)
index_t(2,22)
index_t(2,23)
index_t(3,31)

all the elements with f.e. key == 2 and ignoring the subkey have to be looked up.

Also lookups with given key and subkey must be possible. So using a multiset/map with key as the only container’s key is not a solution.

  • 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-30T15:00:08+00:00Added an answer on May 30, 2026 at 3:00 pm

    You could do

    std::set<index_t>  mySet;
    

    And for searching for all items with a given key and any subkey, do

    std::pair<std::set<index_t>::iterator, std::set<index_t>::iterator> range;
    range.first = mySet.lower_bound(index_t(key, 0));
    range.second = mySet.upper_bound(index_t(key, UINT_MAX));
    

    That’ll preserve 2*log n performance.

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

Sidebar

Related Questions

In what situation would it be more appropriate for me to use a bitset
I created a graphic in Flash CS4 that contains text. I embedded the appropriate
When is it appropriate to use an unsigned variable over a signed one? What
When is it appropriate to use <cflock scope=application> or it's ilk as opposed to
What is the most appropriate media type (formally MIME type) to use when sending
When is it appropriate to use CoTaskMemAlloc? Can someone give an example?
When is it appropriate to use openGl-es on the iPhone versus other toolkits? I
When is it appropriate to use connection pooling and what happens when the maximum
I've implemented some components to use WCF with both an IoC Container (StructureMap) and
Does anyone know what the appropriate mechanism is when creating a custom compound control

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.