Great :D
Thank you both very much.
Maarten
On 02/09/06, James Milne <[EMAIL PROTECTED]> wrote:
On 2 Sep 2006, at 19:27, Maarten de Vries wrote:
> Hi, this might not be the best place to ask (or it might be) but is
> there a
> C++ equivalent for the RB Dictionary? In Borland 6 to be more
> specific... I
> have to finish my app in 60 days (trial runs out then :p).
The nearest equivalent would likely be the stl::map class.
It's a template class, and the first template argument is the Key
type, and the second argument is the Value type.
It follows the standard STL protocol for addition, query and removal.
You can also iterate over the contents.
#include <iostream>
#include <string>
#include <map>
int main (int argc, char * const argv[])
{
std::string key("MyKey");
std::string val("MyValue");
typedef std::map< std::string, std::string > StringMap;
StringMap myStringMap;
// Add a value to the map
myStringMap[ key ] = val;
// Retrieve a value
std::cout << myStringMap[ key ];
std::cout << std::endl;
// Search for a value in the map
StringMap::iterator itr = myStringMap.find(key);
if( itr != myStringMap.end() )
{
std::cout << itr->second;
std::cout << std::endl;
}
// Remove a value from the map
itr = myStringMap.find(key);
if( itr != myStringMap.end() )
{
myStringMap.erase(itr);
}
return 0;
}
--
Kind regards,
James Milne
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>