home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18263 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.3 KB  |  37 lines

  1. Newsgroups: comp.lang.c++
  2. 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
  3. From: porum@county.oz.au (Peter Orum)
  4. Subject: Indirect container classes
  5. Message-ID: <1992Dec20.232025.28984@county.oz.au>
  6. Organization: County NatWest, Sydney
  7. Date: Sun, 20 Dec 92 23:20:25 GMT
  8. Lines: 27
  9.  
  10. Could someone advise on what is the best method of
  11. having a collection of pointers to large objects. The
  12. large objects may appear on more than one list, but I
  13. only want one instance of each object  to be created.
  14.  
  15.     a)    a list of pointers, eg List<String *>
  16.     
  17.     b)    a list class that assumes its  data are pointers
  18.         eg Indirect_List<String *>
  19.         
  20.     c)  use List<String>, but class String is implemented using
  21.         a pointer to a reference-counted String_rep.
  22.         
  23. To  me,  method  a)  is  the easiest to implement but you lose
  24. the  ability  to  test  for  list  membership  by  content, as
  25. comparison is on absolute memory addresses.
  26.  
  27. Method  b)  has  the  disadvantage  of (slightly) complicating
  28. the   List   class, requiring  overloading  of  the  comparison
  29. operators, search & copy functions.
  30.  
  31. Method  c)  complicates the class definition, but means in the
  32. client  code  I  don't have to decide on which type of List to
  33. use, nor whether to use pointers or objects.
  34.  
  35. What do other people do? 
  36.  
  37.