Re: Efficient insertion in a std::multimap
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-12189-1250977143-0002
Content-Type: text/plain; format=flowed; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Barry writes:
On 22 Aug, 20:43, Sam <s...@email-scan.com> wrote:
Store pointers, instead of the actual objects. Of course, that creates =
a
whole bunch of other issues.
application_pgp-signature_part
< 1KVisaH=C3=A4mta
Thanks for the reply. How might I use pointers to do this since I wish
to store many MyObject objects within a Phase Object? If I were to use
pointers, then I would do something like this -
Phase::Phase()
{
MyObject* myObject = new MyObject();
std::pair<double,Note*> pair(0.0,myObject);
insert (pair);
}
But I will be storing a whole bunch of MyObject objects within a Phase
object, so I'm still going to need to keep track of them in order to
delete them in Phase's destructor. But how would I keep track of them?
Of course. As I said, "that creates a whole bunch of other issues".
Specifically, you will need to figure out exactly how and when you're goi=
ng
to allocate your objects from the heap, and how and when you're going to
delete them. The correct solution, of course, depends very closely on you=
r
application and how it is designed.
If the only place in your application that holds pointers to your allocat=
ed
objects is this map, then it makes sense for you to have a suitable
destructor that deletes all the objects that remain in the map upon its
destruction. But, if other parts of your application might also be holdin=
g
pointers to your objects after the map gets destroyed, and if they expect =
to
use them, then you will need to come up with some other strategy, obvious=
ly.
You are the only one who can know the correct answer to your question.
--=_mimegpg-commodore.email-scan.com-12189-1250977143-0002
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEABECAAYFAkqQZXcACgkQx9p3GYHlUOKBJwCfWUMCGfdVC28rtiinvtrneBsb
34gAmQH0RrHvjKpGpETciBrB5egk4P73
=D0XD
-----END PGP SIGNATURE-----
--=_mimegpg-commodore.email-scan.com-12189-1250977143-0002--