954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

unordered pair?

Is there a built in type to store UNordered pairs?

ie. I want these

pair<double, double> a(4.0, 5.0);
pair<double, double> a(5.0, 4.0);


to be equal. Do I have to make a wrapper and override == ?

Thanks,
Dave

daviddoria
Posting Virtuoso
1,996 posts since Feb 2008
Reputation Points: 437
Solved Threads: 204
 

I don't believe there is a built in type to do such a thing (I've never come across anything like that anyway), but you should be able to write your own function to make sure they are equal anyway.

bool equal ( /* pair p1 and p2 */)
{ /*check if p1 first and p2 first are equal
      if so, check if p1 second and p2 second are equal
        if so, return true
    if 1st check not, check if p1 first and p2 second are equal
      if so, check if p1 second and p2 first are equal
        if so, return true
    return false otherwise */
}


I think that would handle each case, but you'd have to test it to make sure.

DemonGal711
Junior Poster
190 posts since Apr 2008
Reputation Points: 18
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You