Home » U++ TheIDE » U++ TheIDE: CodeEditor, Assist++, Topic++ » Help VectorMap !!!
Re: Help VectorMap !!! [message #14012 is a reply to message #12827] |
Wed, 06 February 2008 16:31  |
captainc
Messages: 278 Registered: December 2006 Location: New Jersey, USA
|
Experienced Member |
|
|
You defined VectorMap with 2 Strings. This means that the key for the VectorMap is a String and the Value of each VectorMap entry is a String. There is no Add function for VectorMap taking 3 arguments. If you want to keep ipAddr and port separate, you have to store a different structure as the value in your VectorMap. Hopefully this example can explain it to you:
// Create the VectorMap and add values:
VectorMap<String, Vector<String>> mHostList;
Vector<String> ipAddrAndPort;
ipAddrAndPort.Add(ipAddr);
ipAddrAndPort.Add(port);
mHostList.Add(id, ipAddrAndPort);
// Get values from VectorMap:
for(int i=0; i<mHostList.GetCount(); ++i){ // Loop through all elements in VectorMap
String id = mHostList.GetKey(i); // Get key for this element
Vector<String> ipAddrAndPort = mHostList.Get(id); // Get the element itself
Cout() << id << " -> " << ipAddrAndPort[0] << ":" << ipAddrAndPort[1] << "/n" ; // Output the details
}
Hope that helps explain the mechanisms a bit.
|
|
|
Goto Forum:
Current Time: Mon Apr 28 06:16:36 CEST 2025
Total time taken to generate the page: 0.00675 seconds
|