Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Hashing by key range

This topic is 895 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the code snippet below, how can I test if the range is valid

the comparison with the end of the iterator won't compile.

Thanks

Jack

 

The name NodePairOctant might be confusing here, it means the area that I am poking into, so that it returns the octant that falls in that range

NodePairOctant searchPair(_position, D3DXVECTOR3(1, 1, 1));
auto range = m_octants.equal_range(searchPair);
if (range == m_octants.end())
      return NULL;

for (auto it = range.first; it != range.second; ++it) {
       return it->second;
}
Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement

for (auto it = range.first; it != range.second; ++it) {
       return it->second;
}


That is some funny-looking code. It's a loop, but it immediately returns from the function. Are you sure that's what you want?

Share this post


Link to post
Share on other sites

 

In the code snippet below, how can I test if the range is valid

the comparison with the end of the iterator won't compile.

Thanks

Jack

 

The name NodePairOctant might be confusing here, it means the area that I am poking into, so that it returns the octant that falls in that range

NodePairOctant searchPair(_position, D3DXVECTOR3(1, 1, 1));
auto range = m_octants.equal_range(searchPair);
if (range == m_octants.end())
      return NULL;

for (auto it = range.first; it != range.second; ++it) {
       return it->second;
}

How do you expect to compare a pair of iterators to only one iterator with just the == operator?

I'm normally for using auto in cases like this, but if people cannot understand what's going on because of the lack of readable type information, I'm beginning to wonder whether it's made C++ worse.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!