PDA

View Full Version : Bi-directional Lookup Table



premroxx
21st April 2012, 19:14
I have two columns of data. One has ip address in string format and the other has a numerical value. After toying around with different ways of declaring it, I decided to go with QMap. But the problem is I need to search through all the values in the map for a particular number and find its corresponding key. How can i implement this?

ChrisW67
21st April 2012, 22:15
Two maps or you could use a third-party bi-directional map like Boost::bimap.

If you are mapping the string "192.168.1.1" to QHostAddress("192.168.1.1") or the matching quint32 then you are probably wasting your time.
Bear in mind that if you are mapping a string like "www.google.com" to an address then you can have many addresses for that name, and potentially many names for each address.