Re: Multimap: how to get a key list?
This is a MIME GnuPG-signed message. If you see this text, it means that
your E-mail or Usenet software does not support MIME signed messages.
The Internet standard for MIME PGP messages, RFC 2015, was published in 1996.
To open this message correctly you will need to install E-mail or Usenet
software that supports modern Internet standards.
--=_mimegpg-commodore.email-scan.com-10071-1267398557-0001
Content-Type: text/plain; format=flowed; charset="US-ASCII"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
Rui Maciel writes:
Is there any way to get a list of keys from a multimap besides relying on a couple of nested
loops to assemble that list?
What nested loops? Only one loop is required to iterate over the multimap.
There is no single function that gives you a set of all keys stored in the
multimap, but a single loop is all that's needed to retrieve all the keys.
It's fairly easy to define a template function that gives them to you,
something like this:
template<typename multimap_t>
void keys(const multimap_t &m,
std::set<typename multimap_t::key_type> &k)
{
for (typename multimap_t::const_iterator b(m.begin()), e(m.end());
b != e; ++b)
{
k.insert(b->first);
}
}
The std::set automatically takes care of deduping the multimap's keys.
--=_mimegpg-commodore.email-scan.com-10071-1267398557-0001
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEABECAAYFAkuK950ACgkQx9p3GYHlUOJodACeI6ZpFF2ec8ksf2S8SXLbXi6P
DWcAniBdoOrekvsPDZ2lMYzW2IAcPlcw
=jRDg
-----END PGP SIGNATURE-----
--=_mimegpg-commodore.email-scan.com-10071-1267398557-0001--