Re: associative arrays (hash)
On Tue, 2009-12-22, Larry wrote:
"feverzsj" <feverzsj@gmail.com> ha scritto nel messaggio
news:50b6f89a-e521-4378-89da-e144ce656c45@h40g2000prf.googlegroups.com...
map<std::string,vector<int>> years = {
{ "Maurice",{1913, 1945, 1951, 1967, 2000} },
{ "Martin", {1982, 2003, 2007} },
{ "David", {1927, 1947, 1951, 2004} }
};
So, all in all it is just something like this?
std::map<std::string, std::string> hash;
hash["key"] = "value";
hash.insert(std::make_pair("key2", "value2"));
..etc..
correct?
It's hard to see what your question is but yes, if that compiles it's
correct code. That's not all you have to know about std::map to use
it, though.
I think I wrote earlier that you need a book on C++, but at the very
least check out the STL Programmer's guide at http://www.sgi.com/tech/stl/
Pro: it's very readable and complete
Con: it's pre-standard and differs here and there from
reality (e.g. it includes hash_map as a hashed version of
std::map).
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .