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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:10:28+00:00 2026-06-06T05:10:28+00:00

I have a boost::unordered_multimap< std::vector<int>, float> . The keys that I use to query

  • 0

I have a boost::unordered_multimap< std::vector<int>, float>. The keys that I use to query the multimap may contain additional 0 ints that I’d like to ignore (but the keys inserted in the map never contain 0).

Example:

int main() {
  typedef std::vector<int> Vec;
  typedef boost::unordered_multimap<Vec, float, MyHash, MyEqualKeys> Map;
  Map map;

  Vec vec1;
  vec1.push_back(2);
  vec1.push_back(6);
  map.insert(Map::value_type(vec1, 4.3));
  map.insert(Map::value_type(vec1, 6.8));

  Vec queryVec;
  queryVec.push_back(2);
  queryVec.push_back(0); // additional 0, to be ignored                                                                                                                         
  queryVec.push_back(6);
  for (std::pair<Map::iterator, Map::iterator> iter = map.equal_range(queryVec);
       iter.first != iter.second; ++iter.first) {
    std::cout << iter.first->second << std::endl; // 4.3 and 6.8
  }
}

I wrote a hash function MyHash that ignores the 0 in the key to be hashed.

My question is: When I write MyEqualKeys, is it guaranteed that a query key (which in my case may have additional 0) is always the first argument?

So, when I write this functor:

struct MyEqualKeys {
  bool operator()(Vec const& x, Vec const& y) const {...}
};

Can only the x argument contain the additional 0?

I’d like to know because above I slightly simplified, and in reality I may have to check for more than just a 0 and it may be slightly costly to have to check the y argument too (for millions of queries).

  • 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-06T05:10:30+00:00Added an answer on June 6, 2026 at 5:10 am

    No, there is no such guarantee or requirement (on any of the unordered associative containers). I’d suggest adding a ‘sanitised’ flag to your key objects.

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

Sidebar

Related Questions

I have a boost variant of looking like this: typedef boost::variant<int, float, double, long,
I've just started to use boost multi_index and so far have a container that
i have this iterator loop, typedef boost::unordered_map<std::pair<int, int>, NavigationNode> NodesMap; NodesMap nodes; for (NodesMap::iterator
I Have a object which the following field : boost::unordered_map<std::string, std::shared_ptr<Foo> > m_liste_; I
I have a boost::posix_time::ptime that points to March 31st 2010 like this: ptime p(date(2010,
I'm trying to do the following: I have: std::vector<std::vector<GLdouble[2]>> ThreadPts(4); then I try to
I have the following code: #include <iostream> #include boost/unordered_map.hpp using namespace std; using namespace
I have imported Boost library in to a .dll that I am using. I
I have a boost dynamic_bitset that I am trying to extract the set bits
I need to be able to have boost::program_options parse an array of doubles that

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.