home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!swrinde!network.ucsd.edu!munnari.oz.au!metro!basser.cs.su.oz.au!tmx!synth.county.oz.au!porum
- From: porum@county.oz.au (Peter Orum)
- Subject: Indirect container classes
- Message-ID: <1992Dec20.232025.28984@county.oz.au>
- Organization: County NatWest, Sydney
- Date: Sun, 20 Dec 92 23:20:25 GMT
- Lines: 27
-
- Could someone advise on what is the best method of
- having a collection of pointers to large objects. 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?
-
-