unordered pair?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2008
Posts: 634
Reputation: daviddoria is a jewel in the rough daviddoria is a jewel in the rough daviddoria is a jewel in the rough 
Solved Threads: 46
daviddoria daviddoria is offline Offline
Practically a Master Poster

unordered pair?

 
0
  #1
Mar 23rd, 2009
Is there a built in type to store UNordered pairs?

ie. I want these

  1. pair<double, double> a(4.0, 5.0);
  2. pair<double, double> a(5.0, 4.0);

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

Thanks,
Dave
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 185
Reputation: DemonGal711 is an unknown quantity at this point 
Solved Threads: 10
DemonGal711 DemonGal711 is offline Offline
Junior Poster

Re: unordered pair?

 
0
  #2
Mar 23rd, 2009
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.

  1. bool equal ( /* pair p1 and p2 */)
  2. { /*check if p1 first and p2 first are equal
  3.   if so, check if p1 second and p2 second are equal
  4.   if so, return true
  5.   if 1st check not, check if p1 first and p2 second are equal
  6.   if so, check if p1 second and p2 first are equal
  7.   if so, return true
  8.   return false otherwise */
  9. }

I think that would handle each case, but you'd have to test it to make sure.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC