0

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

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by DemonGal711
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.