home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!spool.mu.edu!sdd.hp.com!network.ucsd.edu!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Indirect container classes
- Message-ID: <1992Dec21.100339.14138@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Dec20.232025.28984@county.oz.au>
- Date: Mon, 21 Dec 1992 10:03:39 GMT
- Lines: 48
-
- In article <1992Dec20.232025.28984@county.oz.au> porum@county.oz.au (Peter Orum) writes:
- >Could someone advise on what is the best method of
- >having a collection of pointers to large objects.
-
- I doubt anyone could advise you on the *best* method,
- at least without risking a few flamethrowers.
-
- >The
- >large objects may appear on more than one list, but I
- >only want one instance of each object to be created.
- >
- > a) a list of pointers, eg List<String *>
- >
- > b) a list class that assumes its data are pointers
- > eg Indirect_List<String *>
- >
- > c) use List<String>, but class String is implemented using
- > a pointer to a reference-counted String_rep.
- >
- >To me, method a) is the easiest to implement but you lose
- >the ability to test for list membership by content, as
- >comparison is on absolute memory addresses.
- >
- >Method b) has the disadvantage of (slightly) complicating
- >the List class, requiring overloading of the comparison
- >operators, search & copy functions.
- >
- >Method c) complicates the class definition, but means in the
- >client code I don't have to decide on which type of List to
- >use, nor whether to use pointers or objects.
- >
- >What do other people do?
- >
-
- c) looks most worth perusing to me. Without reference
- counting (a or b), how do you plan to delete the large objects
- when they are no longer required? (Or rather, how will
- you know when they are no longer required?)
-
- For more techniques purchase Coplien, "Advanced C++
- Programming Styles and Idioms".
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-